Skip to content

msvc compiler warning turned as error are restored to warning #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gzzi opened this issue Sep 24, 2021 · 0 comments · May be fixed by boostorg/vmd#10 or boostorg/preprocessor#40
Open

msvc compiler warning turned as error are restored to warning #563

gzzi opened this issue Sep 24, 2021 · 0 comments · May be fixed by boostorg/vmd#10 or boostorg/preprocessor#40

Comments

@gzzi
Copy link

gzzi commented Sep 24, 2021

Hello,

We would like to compile code with msvc and warning C4002 as error. To do so, we set the compiler flag /we4002.

When we include some boost header, the compiler error 4002 is set back to warning due to this line or this line.

Example:

With a file main.cpp:

#define SUM(a, b)    ((a)+(b))

int main(void)
{
    return SUM(1,2,3);  // note the extra arg 3
}

compiled with

C:\tmp>"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\Hostx64\x64\cl.exe" /we4002 /I. /EHsc main.cpp

it produce error:

Compilateur d'optimisation Microsoft (R) C/C++ version 19.30.30706 pour x64
Copyright (C) Microsoft Corporation. Tous droits réservés.

main.cpp
main.cpp(5): error C4002: trop d'arguments pour l'appel de macro de type fonction 'SUM'

(this is the expected behavior)

but if the file use boost unit_test.hpp:

#define BOOST_TEST_MODULE MyTest
#include <boost/test/unit_test.hpp>

#define SUM(a, b)    ((a)+(b))

int main(void)
{
    return SUM(1,2,3);  // note the extra arg 3
}

compiled with the same command line

C:\tmp>"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\Hostx64\x64\cl.exe" /we4002 /I. /EHsc main.cpp

The extra argument is now accepted by producing only a warning:

Compilateur d'optimisation Microsoft (R) C/C++ version 19.30.30706 pour x64
Copyright (C) Microsoft Corporation. Tous droits réservés.

main.cpp
main.cpp(8): warning C4002: trop d'arguments pour l'appel de macro de type fonction 'SUM'
... <try to link>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant