Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C4275 warning in Visual Studio

Tags:

c++

visual-c++

I get this warning when compiling my code in VS2008

warning C4275: non dll-interface class 'std::runtime_error' used as base for dll-interface class 'MyException' 2> c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdexcept(148) : see declaration of 'std::runtime_error'

My class is defined as

class MyException : public std::runtime_error
like image 221
shergill Avatar asked Mar 06 '11 00:03

shergill


People also ask

How do I enable warnings in Visual Studio?

If you want to turn it on (or off) in the project setting, you have to go to: Configuration Properties -> C/C++ -> Command Line and then under Additional Options you can enter: /w3#### to set your warning to level 3, and thus enable it; or you can enter /wd#### to disable a warning.

What is a warning in C++?

Compiler warnings are messages produced by a compiler regarding program code fragments to be considered by the developer, as they may contain errors. Unlike compilation errors, warnings don't interrupt the compilation process.


1 Answers

MSDN: http://msdn.microsoft.com/en-us/library/3tdb471s.aspx

"An exported class [as in DLL] was derived from a class that was not exported [as in DLL]."

Apparently you are declaring MyException to be exportable from a DLL (by using: __declspec(dllexport)), while std::runtime_error is not exportable. Consider if MyException really needs to be exportable. However, if none of the issues listed on the above page apply to your specific case, then you can disregard that warning--just be aware of the issues.

like image 58
dappawit Avatar answered Oct 24 '22 01:10

dappawit