简体   繁体   中英

typedef error under gcc

in my code, I put following codes

typedef Status int;

I got following errors, it is expected '=', ',', ';', 'asm' or ' attribute ' before 'int' under linux.

I can't find what's probelm. Thanks for your help. a

Use:

typedef int Status;

instead of

typedef Status int;

The syntax of a typedef is the same as the syntax as any ordinary declaration:

int a, b;          // declare int objects a and b
typedef int c, d;  // declare int type-aliases c and d  

The typedef should be followed by the type and then the name. Therefore, the typedef should look like this:

typedef int Status;

The syntax for typedef is

typedef <SOME_TYPE> new_name_for_some_type;

You are swapping the <SOME_TYPE> and new_name_for_some_type elements of the typedef syntax.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM