In C, is it good form to use typedef for a pointer?

前端 未结 8 1670
野性不改
野性不改 2021-01-06 10:46

Consider the following C code:

typedef char * MYCHAR;
MYCHAR x;

My understanding is that the result would be that x is a pointer of type \"

8条回答
  •  时光说笑
    2021-01-06 11:26

    If you look at several existing APIs, it looks as if not putting the pointerness into the type seems better style:

    • the already mentionned FILE *
    • the MYSQL * returned by MySQL's mysql_real_connect()
    • the MYSQL * returned by MySQL's mysql_store_result() and mysql_use_result()

    and probably many others.

提交回复
热议问题