Recently, when dealing with a third party code, it was found that the GCC compiler could not handle double slash annotations correctly (//). After consulting some information, it was found that GCC uses a different C standard to determine whether it can handle double slash annotations correctly.
Because the-ansi switch is added to the cflags in the makefile, and-ansi is equivalent to-std=c89, follow the C89 specification and not be able to handle double slash annotations. Some articles mention adding-wp,-lang-c-c++-comments to GCC to solve this problem, but in practice this option is obsolete after GCC 2.x. The appropriate solution, therefore, is to change-ansi to-std=gnu89 (note not c89), gnu89 the equivalent of c89 plus some GCC extensions, including double slash annotation forms. In addition, note that although written as-std=c99 can also handle double slash annotation, but because the C99 standard incorporates some C + + specification, and ANSI difference is larger, therefore not recommended.