Multifile C projects

spectrecs

Junior Member
Sep 26, 2004
14
0
0
Ok, I'm havin a little bit of a problem that I can't figure out. I'm using a multi-file C project in Visual Studio .NET. I need this to conform to the ANSI C standard.

I'm defining some structures here as:

struct myStruct
{
//blah
};

in some file, lets call it struct_def.h. Ok, now, I want to create an instance of this struct in main.c. What is the correct way to do this? I've tried 3 different ways that I can think of, and it either comes down to I'm "redefining" the struct, or it says I'm trying to create an instance of an unknown structure... could someone provide a basic example?
 

jlarsson

Golden Member
Jul 31, 2001
1,050
0
76
Within main.c, just include the file in the preprocessor ...

#include "struct_def.h"
 

spectrecs

Junior Member
Sep 26, 2004
14
0
0
Thats what I thought.... but its not working. Maybe I'll just try making a simple project just to test this out.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
setup a dummy variable

#ifdef __dummy
#define __dummy

struct
{
}
#endif