Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of "C++ exception specification ignored" warning

I recently got a dll that has been implemented by others. I have to use it in my application. In the header file of their class they have the function declaration

void func1() throw (CCustomException);

Now when i compile it am getting the warning,

C++ exception specification ignored except to indicate a function is not _declspec(nothrow)

I read the MSDN - Documentation but couldn't understand it clearly. Also, I don't want to disable the warning just because it is showing up. I want to know what I am doing wrong instead of disabling it.

I thought my function, say myfunc() accessing that func1() from the dll doesn't have that Exception specification list. Hence I tried having the corresponding exception specification list in my function too as,

void myfunc1() throw (CCustomException);

But I am still getting the warning. What is that warning is all about and how to get rid of it? I am using Qt 4.5 in Windows XP.

like image 686
liaK Avatar asked Jun 29 '10 13:06

liaK


1 Answers

Ok, it is a non-answer, but I would throw away the exception specification and never use it again.

EDIT: I read too fast, and I didn't see you did not write the class yourself. Best way to get rid of warnings in msvc is via #pragma warning(push) followed by #pragma warning(disable:xxxx) where xxxx is the warning code :

#ifdef _MSC_VER 
#pragma warning(push)
#pragma warning(disable:xxxx)
#endif 

...

#ifdef _MSC_VER 
#pragma warning(pop)
#endif

EDIT: It is perfectly safe to disable the warning. Exception specifications are evil, and the compiler is only telling you it is disabling them for you. Even if it breaks the standard.

like image 78
Alexandre C. Avatar answered Oct 16 '22 05:10

Alexandre C.