Is “typedef” in between the type and the alias standard-conformant?

前端 未结 5 534
春和景丽
春和景丽 2021-02-06 20:59

I stumbled upon some code where the typedef keyword is in between the type and the alias name like in

int typedef INT;

It compiles

5条回答
  •  礼貌的吻别
    2021-02-06 21:45

    I compile using:

    gcc -c -Wall -Wextra -pedantic -Wconversion -std=gnu99

    In the background, this means -Wold-style-declaration is set.

    Then the compiler outputs the following warning message:

    warning: 'typedef' is not a beginning of declaration [-Wold-style-declaration]
    

    without that parameter being set, the compiler handles the syntax with no problems

    So the posted syntax is within the standard, but can be confusing to the reader.

提交回复
热议问题