Search code examples
cvisual-studioc99c89

Can I make MSVS 2013 flag declarations after statements?


I have code which is compiled on some platforms in MSVS 2013 and on others in MSVS 2010 (not to mention UNIX and VMS). Since MSVS 2010 does not support declarations after statements (as reported in such posts as “weird-compilation-error-in-visual-studio-2008”), I would (regretfully) like to make MSVS 2013 flag such statements as errors or with warnings (which I will treat as errors).

I have been through the C compiler options for the project, hoping to see a something such as a language standard I could set to C89, but found nothing: I see no way of forcing this — have I missed something there, can I do something else underwater, or must I live with it?

I could in principle do everything in 2010, but 2013 has significantly improvements in Code Analysis and many other areas, so even if I can’t flag errors I shall stick with 2013.


Solution

  • I don't think VS2013 supports this conformance option. Sorry. Must run older compiler, but in doing so you may catch even some other incompatibilities, not just the one you care about.

    One alternative would be to run older compiler in custom build step.

    Another alternative, if you use some source control tool like SVN, is to run older compiler as pre-commit step of the tool.