C typedef struct uncertainty.
Posted
by
Emanuel Ey
on Stack Overflow
See other posts from Stack Overflow
or by Emanuel Ey
Published on 2011-01-12T10:50:17Z
Indexed on
2011/01/12
10:53 UTC
Read the original article
Hit count: 264
Consider the following typedef struct in C:
21:typedef struct source{
22: double ds; //ray step
23: double rx,zx; //source coords
24: double rbox1, rbox2; //the box that limits the range of the rays
25: double freqx; //source frequency
26: int64_t nThetas; //number of launching angles
27: double theta1, thetaN; //first and last launching angle
28:}source_t;
I get the error:
globals.h:21: error: redefinition of 'struct source'
globals.h:28: error: conflicting types for 'source_t'
globals.h:28: note: previous declaration of 'source_t' was here
I've tried using other formats for this definition:
struct source{
...
};
typedef struct source source_t;
and
typedef struct{
...
}source_t;
Which both return the same error. Why does this happen? it looks perfectly right to me.
© Stack Overflow or respective owner