473,624 Members | 2,534 Online
Bytes | Software Development & Data Engineering Community
+ 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 SPPicturePeriod icity; // SP-Picture Periodicity (0=not used)
int BReferencePictu res; //Referenced B coded pictures (0=off, 1=on)
int start_frame_no_ in_this_IGOP;
int BitDepthLuma;
int BitDepthChroma;
int InterSearch16x1 6;
int InterSearch16x8 ;
int InterSearch8x16 ;
int InterSearch8x8;
int InterSearch8x4;
int InterSearch4x8;
int InterSearch4x4;
int Transform8x8Mod e;
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\
}InputParameter s;
In the above structure,for example if i want to initialize the
img_width,img_h eight 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_widt h=176; (or) input->img_width=17 6;
inputs.img_heig ht=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\d esktop\enocoder \encoder.c(4) : error
C2143: syntax error : missing '{' before '.'
c:\documents and settings\hari\d esktop\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 2334
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 SPPicturePeriod icity; // SP-Picture Periodicity (0=not used)
int BReferencePictu res; //Referenced B coded pictures (0=off, 1=on)
int start_frame_no_ in_this_IGOP;
int BitDepthLuma;
int BitDepthChroma;
int InterSearch16x1 6;
int InterSearch16x8 ;
int InterSearch8x16 ;
int InterSearch8x8;
int InterSearch8x4;
int InterSearch4x8;
int InterSearch4x4;
int Transform8x8Mod e;
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\
}InputParameter s;
In the above structure,for example if i want to initialize the
img_width,img_h eight 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_widt h=176; (or) input->img_width=17 6;
inputs.img_heig ht=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\d esktop\enocoder \encoder.c(4) : error
C2143: syntax error : missing '{' before '.'
c:\documents and settings\hari\d esktop\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 SPPicturePeriod icity; // SP-Picture Periodicity (0=not used)
int BReferencePictu res; //Referenced B coded pictures (0=off, 1=on)
int start_frame_no_ in_this_IGOP;
int BitDepthLuma;
int BitDepthChroma;
int InterSearch16x1 6;
int InterSearch16x8 ;
int InterSearch8x16 ;
int InterSearch8x8;
int InterSearch8x4;
int InterSearch4x8;
int InterSearch4x4;
int Transform8x8Mod e;
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\
}InputParameter s;
In the above structure,for example if i want to initialize the
img_width,img_h eight 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_widt h=176; (or) input->img_width=17 6;
inputs.img_heig ht=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\d esktop\enocoder \encoder.c(4) : error
C2143: syntax error : missing '{' before '.'
c:\documents and settings\hari\d esktop\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,bu t 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 SPPicturePeriod icity; // SP-Picture Periodicity (0=not used)
int BReferencePictu res; //Referenced B coded pictures (0=off, 1=on)
int start_frame_no_ in_this_IGOP;
int BitDepthLuma;
int BitDepthChroma;
int InterSearch16x1 6;
int InterSearch16x8 ;
int InterSearch8x16 ;
int InterSearch8x8;
int InterSearch8x4;
int InterSearch4x8;
int InterSearch4x4;
int Transform8x8Mod e;
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\
}InputParamet ers;
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

InputParamete rs inputs,*input=& inputs;

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

inputs.img_wi dth=176; (or) input->img_width=17 6;
inputs.img_he ight=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:
InputParameter s inputs = { 1,2,3,4 };

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

c:\document s and settings\hari\d esktop\enocoder \encoder.c(4) : error
C2143: syntax error : missing '{' before '.'
c:\document s and settings\hari\d esktop\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 SPPicturePeriod icity; // SP-Picture Periodicity (0=not used)
int BReferencePictu res; //Referenced B coded pictures (0=off, 1=on)
int start_frame_no_ in_this_IGOP;
int BitDepthLuma;
int BitDepthChroma;
int InterSearch16x1 6;
int InterSearch16x8 ;
int InterSearch8x16 ;
int InterSearch8x8;
int InterSearch8x4;
int InterSearch4x8;
int InterSearch4x4;
int Transform8x8Mod e;
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\
}InputParamete rs;
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

InputParameter s inputs,*input=& inputs;

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

inputs.img_wid th=176; (or) input->img_width=17 6;
inputs.img_hei ght=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\d esktop\enocoder \encoder.c(4) : error
C2143: syntax error : missing '{' before '.'
c:\documents and settings\hari\d esktop\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
386
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 singleton stuff won't work for me, I need it to work like it does in most every other development lanagauge I've ever used...or at the very least, something close to how you do it in C++ (by using "extern"). Also, if it can't be done, then state that...
11
2547
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 opaque data types to transfer information in between them. At some stage I was stuck and needed to make a variable global, and I also needed to make the struct declaration public to some other parts. Looking through the code I found out that lots...
5
3314
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 together to form an executable. What would be a good place to declare my global variable ? Can I put in in a .h file that gets #included in all the .c's, (athough protected against double inclusion) ? thanks.
12
2569
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, I do not want to rely on this for initialization. Instead, I want to explicity initialize all variables myself. I've looked at tools like Compuware BoundsChecker, which does an amazing job in detecting uninitialized variables, but doesn't...
2
4440
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 */ #include <time.h>
37
2728
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 order - let's say function A, B, C, D. It always calls function A first which is a function that returns a system path. Now all other functions require that variable as well (function A returns a char pointer)
7
3756
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 the C++ version, the structures are classes with virtual access functions. I am working on linux with g++ and it seems that the _vptr part of the class is null. Further use of these classes causes a segmentation fault. Of course if I use new...
4
6008
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 funtion which returns the struct variable and definition of the fun in in file1.cpp . I am getting the error in compilation that "struct_var' has incomplete type and not allowed and return type is incoplete. If i am trying to return the structure...
1
2583
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 launched, then I am allocating the memory on the heap for the internal structures. To print the log messages I am using the below mentioned global variables and time header functions.
0
8231
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8168
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8614
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8330
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7153
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6107
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2603
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 we have to send another system
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.