Search code examples
cvisual-studiovisual-studio-2005commentsc89

Enforce C-style comments in visual studio 2005


In order to enforce C89 code conformance, I would like Visual Studio 2005 not to accept C++-style comments (// my comment), but only C-style comments (/* my comment */).

Is there any available configuration in Visual Studio 2005 for that purpose? Thanks.


Solution

  • Well, sorry for that self-answered question. Everything is there.

    Just in case the link becomes unavailable: you need to enable strict mode (/Za), and add either a pragma or a compiler option in order to activate warnings or errors on these comments:

    • for a warning #pragma warning(1:4001) or /w14001
    • for an error #pragma warning(error:4001) or /we4001

    All the best