By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,260 Members | 1,233 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,260 IT Pros & Developers. It's quick & easy.

Problem With Global Structures

P: n/a

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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a

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

P: n/a
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

P: n/a

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 discussion thread is closed

Replies have been disabled for this discussion.