Overview
Features
Download
Documentation
Community
Add-Ons & Services

Unable to get POCO_DECLARE_EXCEPTION to work

Please post support and help requests here.

Unable to get POCO_DECLARE_EXCEPTION to work

Postby hixxy » 06 Aug 2012, 02:16

Hello,

I've just started experimenting with Poco for the first time and I am unable to get the POCO_DECLARE_EXCEPTION macro to work.

Even trying to compile the following in a file of its own fails:

Code: Select all
#include <Poco/Exception.h>

POCO_DECLARE_EXCEPTION(Test_API, TestException, Poco::RuntimeException);


hixxy@dev:~/test/src{}$ g++ test.cpp
test.cpp:3: error: expected initializer before ‘:’ token
hixxy@dev:~/test/src{}$

I am using the latest Poco version compiled on Debian Squeeze only yesterday.

Thanks
hixxy
 
Posts: 2
Joined: 06 Aug 2012, 02:11

Re: Unable to get POCO_DECLARE_EXCEPTION to work

Postby lihui7115 » 07 Aug 2012, 05:18

I think you need to use "POCO_IMPLEMENT_EXCEPTION" to implement the declaration.
See the "Exception.cpp", you will get it
lihui7115
 
Posts: 3
Joined: 26 Jul 2012, 11:59

Re: Unable to get POCO_DECLARE_EXCEPTION to work

Postby guenter » 08 Aug 2012, 07:29

Have you declared the Test_API macro? This is needed on Windows to add DLL export keywords to class declarations. On other platforms, or if you don't write a DLL, just define it as empty, e.g.:
Code: Select all
#define Test_API
guenter
 
Posts: 1117
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Unable to get POCO_DECLARE_EXCEPTION to work

Postby hixxy » 08 Aug 2012, 12:10

I had not declared the Test_API. I actually had no idea what it was, but it fixes that error, but now when I add in the implementation macro, I get an error because typeid is used without the typeinfo header being included.

Code: Select all
test.cpp: In member function ‘virtual const char* TestException::className() const’:
test.cpp:6: error: must #include <typeinfo> before using typeid


If the macros in Poco/Exception.h use typeid in their generated code, shouldn't the header be included in Poco/Exception.h?
hixxy
 
Posts: 2
Joined: 06 Aug 2012, 02:11


Return to Support

Who is online

Users browsing this forum: alex and 1 guest

cron