P
Pietro Cerutti
Hi Group,
suppose test1.c, test2.c and test.h
/*** BEGIN TEST.H ***/
#ifndef _TEST_H
#define _TEST_H
typedef struct
{
unsigned int code;
const char *name;
} test_struct;
test_struct structs[NOF_STRUCTS] =
{
{ 12, "twelve" },
{ 11, "eleven" }
};
int test_func(void);
#endif /* !_TEST_H */
/*** END TEST.H ***/
/*** BEGIN TEST1.C ***/
#include <stdio.h>
#include "test.h"
int main(void)
{
return (0);
}
/*** END TEST1.C ***/
/*** BEGIN TEST2.C ***/
#include "test.h"
int test_func(void)
{
return (2);
}
/*** TEST2.C ***/
/var/tmp//ccLatz7e.o(.data+0x0): first defined here
Why is the header file parsed twice (and thus structs defined twice),
even when I started the header file with #ifndef etc etc statements?
Thank you!
suppose test1.c, test2.c and test.h
/*** BEGIN TEST.H ***/
#ifndef _TEST_H
#define _TEST_H
typedef struct
{
unsigned int code;
const char *name;
} test_struct;
test_struct structs[NOF_STRUCTS] =
{
{ 12, "twelve" },
{ 11, "eleven" }
};
int test_func(void);
#endif /* !_TEST_H */
/*** END TEST.H ***/
/*** BEGIN TEST1.C ***/
#include <stdio.h>
#include "test.h"
int main(void)
{
return (0);
}
/*** END TEST1.C ***/
/*** BEGIN TEST2.C ***/
#include "test.h"
int test_func(void)
{
return (2);
}
/*** TEST2.C ***/
/var/tmp//ccZgBLuP.o(.data+0x0): multiple definition of `structs'gcc -ggdb -o test test1.c test2.c
/var/tmp//ccLatz7e.o(.data+0x0): first defined here
Why is the header file parsed twice (and thus structs defined twice),
even when I started the header file with #ifndef etc etc statements?
Thank you!