How to enforce C89-style variable declarations in gcc?

前端 未结 3 1013
执笔经年
执笔经年 2021-02-07 23:55

I work on a code base which is mostly C with a little C++, and is mostly built with gcc but occasionally it needs to be built with MSVC. Microsoft\'s C compiler is still pretty

3条回答
  •  孤独总比滥情好
    2021-02-08 00:37

    It is not Win32 that renders the code uncompilable, but the compiler. You can use GCC on Win32 and get greater cross-platform compatibility.

    Another possibility is to use C++ compilation for your Win32 build; the GCC compilation will already have determined that it is valid C, and C++ compilation will generally make it stronger C too.

    [edit] Another solution is to use a continuous integration server such as CruiseControl configured so that whenever the GCC platform coders check-in code, the CI server can check it out and build it using VC++ (or even apply a third-party static analysis tool) and on error e-mail the results to the user who checked in the erroneous code. This solution may be heavyweight for the original problem, but may yield many other benefits besides.

提交回复
热议问题