簡體   English   中英

C90 和 typedef

[英]C90 and typedef

我有struct point {(...)}; 定義。 但是對於 C90,似乎我必須使用 typedef 來完成。 我該如何正確地做到這一點? typedef struct point {} point; ? typedef struct {} point; ? typedef struct point {}; ?

你可以做:

typedef struct Point { ... } MyPoint;

然后使用兩種聲明:

struct Point p1;
MyPoint p2;

這兩個都是正確的:

typedef struct point { /* ... */ } point;
typedef struct { /* ... */ } point;

第一個版本定義了struct point ,然后將point定義為它的別名,而第二個版本將point定義為匿名結構的別名。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM