Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

MSVC compiler warning c4984

I’m trying to implement a DLL and offer some interfaces to a legacy VS2017 C++14 project which I cannot control. (Original Post).
I want to use if constexpr expression in my header files, and found the compiler would complain about C4984. Not sure what is the meaning "portable":

If you require C++11 or C++14 compatibility, this expression isn’t portable.

C4984 is issued as an error by default, but it’s suppressible.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I added #pragma warning(disable : 4984) before my if constexpr expression, and found the legacy project can compile and operate well, so do I need to worry about the "portable" things?

>Solution :

if constexpr is a C++17 feature. It can’t be used in C++14. If a compiler is allowing it in C++14 mode (with a warning), then this is as an extension. Other compilers, especially older ones, will not do so.

#pragma warning(disable : 4984) is certainly not portable. It is MSVC-specific.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading