displaying #define values in C

后端 未结 4 591
孤独总比滥情好
孤独总比滥情好 2021-01-29 04:32

I have a series of #defines from a library file header of this sort:

typedef int Lib_error;   

#define   LIB_ERROR_A      ((Lib_error) 0x0000) 
#define   LIB_ER         


        
4条回答
  •  臣服心动
    2021-01-29 05:03

    People seem to have mixed feelings about them, but X-macros are one possible solution.

    But if you can't change the header, then your only two options (AFAIK) are:

    • Doing it manually
    • Some form of code generation step in your build process. In your case, it should probably be possible by parsing the header file with sed (assuming you're working on Linux).

提交回复
热议问题