Max identifier length

前端 未结 4 649
野趣味
野趣味 2020-12-08 22:09

Where can I find what is the maximum identifier length in C?

In which header file is that limit specified?

4条回答
  •  一个人的身影
    2020-12-08 22:47

    Since there are some bizarre corner cases where it is helpful to have code aware of the limit, here is a method that can be placed in a (albeit hideous to look at) header file:

    #define SOMEREALLYREALLY...REALLYLONGNAME 1
    #if SOMEREALLYREALLY
    #define MAXIDENT 16
    #elif SOMEREALLYREALLYR
    #define MAXIDENT 17
    #elif SOMEREALLYREALLYRE
    #define MAXIDENT 18
    ...and so on
    

    Eventually, the #ifs will either hit truncated identifier, or the full identifier if the compiler doesn't truncate

提交回复
热议问题