Is typedef ever required in C?

前端 未结 15 2849
夕颜
夕颜 2021-02-13 14:19

Typedef is very useful for portable names, tag names (typedef struct foo Foo;) and keeping complicated (function) declarations readable (typedef int (*cmpfunc

15条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-13 15:08

    The keyword typedef is definitely needed in test suites that check a C compiler for ISO-C compliance.

    In code that is not explicitly supposed to use typedef (like the test suite above) it is often very helpful but never essential because it only establishes an alias to another type. It does not create a type.

    Finally, I would not count things like avoiding a compiler limit on preprocessed source file size through the abbreviation typedefs can offer.

提交回复
热议问题