-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Squelch MSVC warning exporting subclasses of runtime_error #1433
Conversation
After I looked more at the code and saw how What I have here is one potential solution to fix the warning. One of the only things that may-or-may-not matter is that it will suppress this warning now for everything - So in the future if you actually did make the mistake of exporting a class without exporting its parent, no warning would be given. Alternatively, I suppose it's possible to use |
I would advise for using Edit: Line 160 in bb205d9
|
When compiling {fmt} as a DLL, MSVC complains that we are exporting classes that inherit from "std::runtime_error", which we are not exporting. In this case, it's not really a problem because that symbol is already exported via the C++ stdlib. So we just add a pragma to silence the warning.
Indeed - It also appears that MSVC supports this Perhaps you like this solution better? |
Thanks! |
Based on pr fmtlib#1433 with changes to deal with issue fmtlib#1450 "When compiling {fmt} as a DLL, MSVC complains that we are exporting classes that inherit from "std::runtime_error", which we are not exporting. In this case, it's not really a problem because that symbol is already exported via the C++ stdlib. So we just add a pragma to silence the warning." Puts a pragma before the relevant class def instead of within it's declaration for greater support among older msvc.
Based on pr fmtlib#1433 with changes to deal with issue fmtlib#1450 "When compiling {fmt} as a DLL, MSVC complains that we are exporting classes that inherit from "std::runtime_error", which we are not exporting. In this case, it's not really a problem because that symbol is already exported via the C++ stdlib. So we just add a pragma to silence the warning." Puts a pragma before the relevant class def instead of within it's declaration for greater support among older msvc.
…#1433) (#1470) * Squelch MSVC warning exporting subclasses of runtime_error When compiling {fmt} as a DLL, MSVC complains that we are exporting classes that inherit from "std::runtime_error", which we are not exporting. In this case, it's not really a problem because that symbol is already exported via the C++ stdlib. So we just add a pragma to silence the warning. * Fix compilation with MinGW Commit 3bc28fc ("Squelch MSVC warning exporting subclasses of runtime_error", 2019-11-29) silenced a MSVC warning under. The MinGW compiler also defines _WIN32, but does not support the "warning" pragma. Introduce a helper macro to squelch the MSVC warning only when using the Microsoft compiler. Signed-off-by: Beat Bolli <dev@drbeat.li> * Fix compilation with VS2015 (#1450) VS2015 does not support the __pragma(...) syntax in the midst of a class declaration, so move it to just before the declaration.
When compiling {fmt} as a DLL, MSVC complains that we are exporting
classes that inherit from "std::runtime_error", which we are not
exporting.
In this case, it's not really a problem because that symbol is already
exported via the C++ stdlib. So we just add a pragma to silence the
warning.
I agree that my contributions are licensed under the {fmt} license, and agree to future changes to the licensing.