Suppressing warning C4290 (when building with MSVC)
- From: John Emmas <johne53 tiscali co uk>
- To: gtkmm-list gnome org
- Subject: Suppressing warning C4290 (when building with MSVC)
- Date: Fri, 28 Jun 2013 09:13:39 +0100
Hi guys,
This morning I added these 3 x lines at line 6 of 'glib/glibmm/variant.h' :-
#ifdef _MSC_VER
#pragma warning(disable:4290)
#endif
The added lines suppress hundreds of compiler warnings that I was
previously getting when trying to build with MSVC. The warnings all
took the following form:-
warning C4290: C++ exception specification ignored except to
indicate a function is not __declspec(nothrow)
Each warning was generated at a line looking something like this:-
static V_CastTo cast_dynamic(const VariantBase& v)
throw(std::bad_cast);
Basically, MSVC (I think) ignores exception specifiers that are too
specific - e.g. throw(std::bad_cast) - for the reasons stated here:-
http://stackoverflow.com/questions/88573/should-i-use-an-exception-specifier-in-c
Adding the above lines means that I can now build glibmm and giomm
without seeing any compiler warnings at all which is a big improvement,
so I thought I might as well flag it up. There are 5 such exception
specifiers in variant.h, at lines 408, 436, 680, 866 and 923. I guess
different people will have different views so I don't know whether a
tidier solution would be to remove the offending exception specifiers?
Or to add the #pragma? The above article suggests that exception
specifiers are now deprecated anyway - but OTOH, gcc helpfully generates
a warning if your code violates the exception specifier(s) so I guess
that's quite useful. Regards.
John
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]