Hello,

I am a C programmer. I program micro-controllers... mainly PICs.

I have a C question about where structure definitions should reside. Most of us create a pair of files called xxx.h and xxx.c and usually put the structure's definition in the header file along with function prototypes. We then put our function implementations in the xxx.c file.

Lately I took a look at the WinUser.h file and to my surprise I have seen many strutures defined in this file. So why do they define structures in one big common header called WinUser.h when we were taught to define every structure in its own header file in respect to its associated .c file?

For example, in my project I have a header file called "UDT.h" and this header file contains two (2) structures. I also have a .c file called "UDT.c" which holds all the function implementations that manipulate the structure's data. Here is the header file:

Code:
=========================================UDT.h
typedef struct 	T_udt 	udt;

typedef struct tag_fields  
{
unsigned short LKdct__F1; 
unsigned short LKdct__F2;                    				  
unsigned short  LKdct__F3;  
unsigned short  quit_flag;                    			
unsigned short  title_msg1;  					
}Tfields; 

struct T_udt  
{ 								 
unsigned short f__pc_xchoice; 				        
unsigned short f__list_lenght; 				
unsigned short IndexesUsed;
Tfields	*fields;                     
}; 
=====================================

Now there is three (3) ways we can do this, where we can:

A) Define the two (2) structures in the same header file as done above

OR

B) Define only the "tag_fields" structure in a "Com.h" header (like the WinUser.h does) and keep the "T_udt" structure in the "UDT.h" file

OR

C) Define both structures in a "Com.h" header (like the WinUser.h does)

Which would be to most politically correct way to do this. Confused.

All feedback or help is appreciated.

rob