In our cross-platform Open Source library, we get from std :: exception to define custom exceptions that can be caught in library code as well as in user code. I saw that this is really the recommended procedure, but in Visual Studio 2015 (or rather, in the new version of MSVC) a warning is added to the implementation class ( warning C4275 ) - see also here: How is the dllexport class derived from std :: runtime_error?
Of course, we could just ignore the mistake, but it seems wrong to me.
The reason for the warning compared with older versions of Visual Studio, apparently, is that std :: exception is used for export in an older version of MSVC, but so far it is no longer exported. In any case, I feel that this was never the “right way” to continue in the form of compiling it into a library.
From what I read in the answers, the best way to do this is to “embed” the class, since exporting the base class (std :: exception) can lead to more complications. If I understand correctly, "inlining" here means not using the keyword "inline", but moving the definition to the header and not exporting it. Is that even right?
Assuming this is what is meant: my question is that a compiled library that throws exceptions that are defined in one of its headers will allow you to correctly catch exceptions in the executable, dynamically linking this library. But what if the compilers are different? Runtime type information (RTTI) seems relevant here, so is it guaranteed to work in this way even when using different versions of the compiler or even different compilers? If this does not work, how to solve it in the “right” way?
Ident source share