[問題] typedef問題

看板C_and_CPP (C/C++)作者 (Richie)時間16年前 (2009/05/26 00:17), 編輯推噓0(004)
留言4則, 2人參與, 最新討論串1/1
typedef float GLfloat;==>gl.h 程式中宣告 GLfloat f=0.0f出現error C2275: 'GLfloat' : illegal use of this type as an expression 可是直接宣告 float f=0.0f; 出現 error C2143: syntax error : missing ';' before 'type' // C2275.cpp 的錯誤原因 typedef struct S { int mem; } *S_t; void func1( int *parm ); void func2() { func1( &S_t->mem ); // C2275, S_t is a typedef } 可是float 不是個struct這到底要怎宣才對? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.117.1.229

05/26 00:22, , 1F
找到原因了把.C改成CPP可是如果是.C要怎辦?
05/26 00:22, 1F

05/26 00:47, , 2F
通常會遇到這種問題 是因為你用了C++的語法
05/26 00:47, 2F

05/26 00:47, , 3F
所以如果副檔名用.c compiler會以C format下去compile
05/26 00:47, 3F

05/26 00:48, , 4F
碰到C++的語法 就有可能出錯
05/26 00:48, 4F
文章代碼(AID): #1A6iIoGj (C_and_CPP)
文章代碼(AID): #1A6iIoGj (C_and_CPP)