Encountered an inexplicable situation trying to build a Linux project with Visual Studio Professional 2019: some preprocessor switches seemed to be ignored by g++ preprocessor -in header files only.
Found some related questions, but users seemed to have found their own issues by either enabling -v (verbose) option, or explicitly passing the preprocessor options with -D flag.Although I've tried both, neither worked for me.
Some of the warnings were about "unknown pragma" messages, which looked inoffensive, making me believe the preprocessor recovered from these warnings -otherwise they should have been errors, not warnings, right ?
These are the pragmas:
#pragma warning (disable:4996)#pragma warning (disable:4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)#pragma warning (disable:4503) // decorated name length exceeded, name was truncated
It was only until I put those pragmas inside WIN32 compilation switch that I managed to compile that project.
The pragmas were not actually targeting the Linux distribution, but the Windows one -for the Microsoft C++ preprocessor. Thus, on the compilation switch, the g++ preprocessor would not stumble on these "unknown pragmas" and then, the preprocessor switches in the header files were taken into account and the project compiled. The project is a huge one, and generated tens of thousands of compilation errors, cannot be put here, but I hope I provided enough explanations around the issue.
Did anybody encountered this too, and can point me to the documentation lines that g++ preprocessor would not "recover" after few warnings related to "unknown pragmas" ?