作者RichieRich (Richie)
看板C_and_CPP
標題[問題] typedef問題
時間Tue May 26 00:17:53 2009
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
→ RichieRich:找到原因了把.C改成CPP可是如果是.C要怎辦? 05/26 00:22
→ OgamiIchiro:通常會遇到這種問題 是因為你用了C++的語法 05/26 00:47
→ OgamiIchiro:所以如果副檔名用.c compiler會以C format下去compile 05/26 00:47
→ OgamiIchiro:碰到C++的語法 就有可能出錯 05/26 00:48