考慮以下typedef結構在C:çtypedef結構的不確定性
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;
我得到的錯誤:
globals.h:21:錯誤:28: '結構源'
globals.h的重新定義:28::注:錯誤:「source_t」
globals.h衝突的類型「source_t」先前的聲明在這裏
我已經使用其他格式的這個定義嘗試:
struct source{
...
};
typedef struct source source_t;
和
typedef struct{
...
}source_t;
兩者均返回相同的錯誤。 這是爲什麼發生?它看起來完全適合我。
看起來像「globals.h」文件從源文件中獲取兩次 – SirDarius 2011-01-12 10:55:29
完美適合我:http://ideone.com/kKj8q – eckes 2011-01-12 10:57:31
基於SirDarius的評論:你有沒有設置一個** reinclude保護**在`globals.h`中? – eckes 2011-01-12 10:58:29