473,466 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem With Global Structures


Good Day,
I am writing a code for the H.264 Video codec.I am using VC++
compiler,but programming is in c only.I have grouped the related global
variables under one structure in a header file called global.h.Like
this i have two three structures in global.h.

To initialise the structure members in global.h,I declared structure
variables in c files wherever the structure members are used.

For example
This is one of the structure in global.h

typedef struct
{
int YUV;
int img_height;
int img_width;
int intra_period;
int IntraPeriod;//period of I-frames
int SPPicturePeriodicity; // SP-Picture Periodicity (0=not used)
int BReferencePictures; //Referenced B coded pictures (0=off, 1=on)
int start_frame_no_in_this_IGOP;
int BitDepthLuma;
int BitDepthChroma;
int InterSearch16x16;
int InterSearch16x8;
int InterSearch8x16;
int InterSearch8x8;
int InterSearch8x4;
int InterSearch4x8;
int InterSearch4x4;
int Transform8x8Mode;
int symbolMode;//Symbol mode (Entropy coding method: 0=UVLC, 1=CABAC)
int EnableIPCM;
int NoBframes;//no of b frames to be inserted
int UseHadamard;// Hadamard SymbolModeform (0=not used, 1=used)
int FrameSkip;//no of frames to be skipped
int RDopt;//2 means Fast High Complexity Mode\
}InputParameters;
In the above structure,for example if i want to initialize the
img_width,img_height variables with some value in a c file where it is
used,for example call it encoder.c,I have declared structure variable
like as

InputParameters inputs,*input=&inputs;

Now i can initialize the variable in any of the following ways

inputs.img_width=176; (or) input->img_width=176;
inputs.img_height=144; (or)input->img_height=144;

But i am getting the following error when i comile the c file,encoder.c

c:\documents and settings\hari\desktop\enocoder\encoder.c(4) : error
C2143: syntax error : missing '{' before '.'
c:\documents and settings\hari\desktop\enocoder\encoder.c(4) : error
C2059: syntax error : '.'

Can you suggest any other way for initailsing the structure member
variables direclty with some values.....

Thanks in advance

Sep 27 '06 #1
4 2322
Harry wrote:
Good Day,
I am writing a code for the H.264 Video codec.I am using VC++
compiler,but programming is in c only.I have grouped the related global
variables under one structure in a header file called global.h.Like
this i have two three structures in global.h.

To initialise the structure members in global.h,I declared structure
variables in c files wherever the structure members are used.

For example
This is one of the structure in global.h

typedef struct
{
int YUV;
int img_height;
int img_width;
int intra_period;
int IntraPeriod;//period of I-frames
int SPPicturePeriodicity; // SP-Picture Periodicity (0=not used)
int BReferencePictures; //Referenced B coded pictures (0=off, 1=on)
int start_frame_no_in_this_IGOP;
int BitDepthLuma;
int BitDepthChroma;
int InterSearch16x16;
int InterSearch16x8;
int InterSearch8x16;
int InterSearch8x8;
int InterSearch8x4;
int InterSearch4x8;
int InterSearch4x4;
int Transform8x8Mode;
int symbolMode;//Symbol mode (Entropy coding method: 0=UVLC, 1=CABAC)
int EnableIPCM;
int NoBframes;//no of b frames to be inserted
int UseHadamard;// Hadamard SymbolModeform (0=not used, 1=used)
int FrameSkip;//no of frames to be skipped
int RDopt;//2 means Fast High Complexity Mode\
}InputParameters;
In the above structure,for example if i want to initialize the
img_width,img_height variables with some value in a c file where it is
used,for example call it encoder.c,I have declared structure variable
like as

InputParameters inputs,*input=&inputs;

Now i can initialize the variable in any of the following ways

inputs.img_width=176; (or) input->img_width=176;
inputs.img_height=144; (or)input->img_height=144;
This is assignment not initialization, and needs to be done within a
function body.

If you want to initialize it:
InputParameters inputs = { 1,2,3,4 };

With C99, you can specify which members to initialize:
InputParameters inputs = { .img_width=176,.img_height=144};
But i am getting the following error when i comile the c file,encoder.c

c:\documents and settings\hari\desktop\enocoder\encoder.c(4) : error
C2143: syntax error : missing '{' before '.'
c:\documents and settings\hari\desktop\enocoder\encoder.c(4) : error
C2059: syntax error : '.'

Can you suggest any other way for initailsing the structure member
variables direclty with some values.....

Thanks in advance
Sep 27 '06 #2

Nils O. Selåsdal wrote:
Harry wrote:
Good Day,
I am writing a code for the H.264 Video codec.I am using VC++
compiler,but programming is in c only.I have grouped the related global
variables under one structure in a header file called global.h.Like
this i have two three structures in global.h.

To initialise the structure members in global.h,I declared structure
variables in c files wherever the structure members are used.

For example
This is one of the structure in global.h

typedef struct
{
int YUV;
int img_height;
int img_width;
int intra_period;
int IntraPeriod;//period of I-frames
int SPPicturePeriodicity; // SP-Picture Periodicity (0=not used)
int BReferencePictures; //Referenced B coded pictures (0=off, 1=on)
int start_frame_no_in_this_IGOP;
int BitDepthLuma;
int BitDepthChroma;
int InterSearch16x16;
int InterSearch16x8;
int InterSearch8x16;
int InterSearch8x8;
int InterSearch8x4;
int InterSearch4x8;
int InterSearch4x4;
int Transform8x8Mode;
int symbolMode;//Symbol mode (Entropy coding method: 0=UVLC, 1=CABAC)
int EnableIPCM;
int NoBframes;//no of b frames to be inserted
int UseHadamard;// Hadamard SymbolModeform (0=not used, 1=used)
int FrameSkip;//no of frames to be skipped
int RDopt;//2 means Fast High Complexity Mode\
}InputParameters;
In the above structure,for example if i want to initialize the
img_width,img_height variables with some value in a c file where it is
used,for example call it encoder.c,I have declared structure variable
like as

InputParameters inputs,*input=&inputs;

Now i can initialize the variable in any of the following ways

inputs.img_width=176; (or) input->img_width=176;
inputs.img_height=144; (or)input->img_height=144;
This is assignment not initialization, and needs to be done within a
function body.

If you want to initialize it:
InputParameters inputs = { 1,2,3,4 };

With C99, you can specify which members to initialize:
InputParameters inputs = { .img_width=176,.img_height=144};
But i am getting the following error when i comile the c file,encoder.c

c:\documents and settings\hari\desktop\enocoder\encoder.c(4) : error
C2143: syntax error : missing '{' before '.'
c:\documents and settings\hari\desktop\enocoder\encoder.c(4) : error
C2059: syntax error : '.'

Can you suggest any other way for initailsing the structure member
variables direclty with some values.....

Thanks in advance

I know that this is the way to assign values to structrure member
variables,but if there are too many variables in the structure we can't
go on like...{2,6,7,........}.......what is wrong with my way of
assigning the initial values to the structure member variables

Sep 27 '06 #3
Harry wrote:
Nils O. Selåsdal wrote:
>Harry wrote:
>>Good Day,
I am writing a code for the H.264 Video codec.I am using VC++
compiler,but programming is in c only.I have grouped the related global
variables under one structure in a header file called global.h.Like
this i have two three structures in global.h.

To initialise the structure members in global.h,I declared structure
variables in c files wherever the structure members are used.

For example
This is one of the structure in global.h

typedef struct
{
int YUV;
int img_height;
int img_width;
int intra_period;
int IntraPeriod;//period of I-frames
int SPPicturePeriodicity; // SP-Picture Periodicity (0=not used)
int BReferencePictures; //Referenced B coded pictures (0=off, 1=on)
int start_frame_no_in_this_IGOP;
int BitDepthLuma;
int BitDepthChroma;
int InterSearch16x16;
int InterSearch16x8;
int InterSearch8x16;
int InterSearch8x8;
int InterSearch8x4;
int InterSearch4x8;
int InterSearch4x4;
int Transform8x8Mode;
int symbolMode;//Symbol mode (Entropy coding method: 0=UVLC, 1=CABAC)
int EnableIPCM;
int NoBframes;//no of b frames to be inserted
int UseHadamard;// Hadamard SymbolModeform (0=not used, 1=used)
int FrameSkip;//no of frames to be skipped
int RDopt;//2 means Fast High Complexity Mode\
}InputParameters;
In the above structure,for example if i want to initialize the
img_width,img_height variables with some value in a c file where it is
used,for example call it encoder.c,I have declared structure variable
like as

InputParameters inputs,*input=&inputs;

Now i can initialize the variable in any of the following ways

inputs.img_width=176; (or) input->img_width=176;
inputs.img_height=144; (or)input->img_height=144;
This is assignment not initialization, and needs to be done within a
function body.

If you want to initialize it:
InputParameters inputs = { 1,2,3,4 };

With C99, you can specify which members to initialize:
InputParameters inputs = { .img_width=176,.img_height=144};
>>But i am getting the following error when i comile the c file,encoder.c

c:\documents and settings\hari\desktop\enocoder\encoder.c(4) : error
C2143: syntax error : missing '{' before '.'
c:\documents and settings\hari\desktop\enocoder\encoder.c(4) : error
C2059: syntax error : '.'

Can you suggest any other way for initailsing the structure member
variables direclty with some values.....

Thanks in advance


I know that this is the way to assign values to structrure member
variables,but if there are too many variables in the structure we can't
go on like...{2,6,7,........}.......what is wrong with my way of
assigning the initial values to the structure member variables
There is nothing wrong with that, but as I said you need to do that
within a function body. It is unclear if your code tries to do that
at file scope - which is not legal. So, put that code in main, or
another function you call pretty quick..
As I also mentioned, provided you have a C99 compiler, you can
specify which members to initialize. I'm not sure this is supported
by Microsoft..
Sep 27 '06 #4

Nils O. Selåsdal wrote:
Harry wrote:
Nils O. Selåsdal wrote:
Harry wrote:
Good Day,
I am writing a code for the H.264 Video codec.I am using VC++
compiler,but programming is in c only.I have grouped the related global
variables under one structure in a header file called global.h.Like
this i have two three structures in global.h.

To initialise the structure members in global.h,I declared structure
variables in c files wherever the structure members are used.

For example
This is one of the structure in global.h

typedef struct
{
int YUV;
int img_height;
int img_width;
int intra_period;
int IntraPeriod;//period of I-frames
int SPPicturePeriodicity; // SP-Picture Periodicity (0=not used)
int BReferencePictures; //Referenced B coded pictures (0=off, 1=on)
int start_frame_no_in_this_IGOP;
int BitDepthLuma;
int BitDepthChroma;
int InterSearch16x16;
int InterSearch16x8;
int InterSearch8x16;
int InterSearch8x8;
int InterSearch8x4;
int InterSearch4x8;
int InterSearch4x4;
int Transform8x8Mode;
int symbolMode;//Symbol mode (Entropy coding method: 0=UVLC, 1=CABAC)
int EnableIPCM;
int NoBframes;//no of b frames to be inserted
int UseHadamard;// Hadamard SymbolModeform (0=not used, 1=used)
int FrameSkip;//no of frames to be skipped
int RDopt;//2 means Fast High Complexity Mode\
}InputParameters;
In the above structure,for example if i want to initialize the
img_width,img_height variables with some value in a c file where it is
used,for example call it encoder.c,I have declared structure variable
like as

InputParameters inputs,*input=&inputs;

Now i can initialize the variable in any of the following ways

inputs.img_width=176; (or) input->img_width=176;
inputs.img_height=144; (or)input->img_height=144;
This is assignment not initialization, and needs to be done within a
function body.

If you want to initialize it:
InputParameters inputs = { 1,2,3,4 };

With C99, you can specify which members to initialize:
InputParameters inputs = { .img_width=176,.img_height=144};

But i am getting the following error when i comile the c file,encoder..c

c:\documents and settings\hari\desktop\enocoder\encoder.c(4) : error
C2143: syntax error : missing '{' before '.'
c:\documents and settings\hari\desktop\enocoder\encoder.c(4) : error
C2059: syntax error : '.'

Can you suggest any other way for initailsing the structure member
variables direclty with some values.....

Thanks in advance

I know that this is the way to assign values to structrure member
variables,but if there are too many variables in the structure we can't
go on like...{2,6,7,........}.......what is wrong with my way of
assigning the initial values to the structure member variables

There is nothing wrong with that, but as I said you need to do that
within a function body. It is unclear if your code tries to do that
at file scope - which is not legal. So, put that code in main, or
another function you call pretty quick..
As I also mentioned, provided you have a C99 compiler, you can
specify which members to initialize. I'm not sure this is supported
by Microsoft..
Thanks for your help dude

Sep 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Relaxin | last post by:
How can I have a variable that has been initialized and set to a value within one source file (*.cs), and have access to that same variable in other files of the same project? NOTE: That...
11
by: Capstar | last post by:
Hi, I am working on an application, which will run embedded without an OS. The app is build up out of a couple of well defined parts. At first I wanted to keep those parts seperated and use...
5
by: luc wastiaux | last post by:
Hello, I need to share a global variable between functions, and for clarity reasons, my code is split in different .c files that each compile into a ..o (object) which in turn are compiled...
12
by: jyu.james | last post by:
I'm trying to detect reads of uninitialized global variables (that are declared in one file, and used in another as an extern). I know that ANSI C initializes all global variables to 0, however,...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
37
by: eoindeb | last post by:
Sorry to ask another global variable question, but from reading other posts I'm still not sure whether to use them or not. I have a program with a set function that calls 4 other functions in...
7
by: ds | last post by:
Hello all, I have a problem with calloc I have never seen before. I am migrating some C code to C++ and at some part in the C code there is a calloc that creates an array of structures. Now in...
4
by: sharat | last post by:
Hi all. I am writing a a code in c++ . i have defined a global structure in a header file(user define header file) say headerfile1.h and declared a class in file2.h which is having some public...
1
by: sunil | last post by:
Hi, Am developing one shared library for one application. In that .so am having one global array of structure ( two more different structure pointers in this struct). Once the application is...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.