Understanding unlimited arguments with ...

  • Thread starter Kevin Grigorenko
  • Start date
K

Kevin Grigorenko

Hello,

I've been using Visual Studio.NET for some time, and I had this
definition of a function in a class:

void throwIt(int id, ErrorType type, ...) throw(...);

I am trying to port my code over to linux to work with G++, and I
received this error:

parse error before `...' token

Am I using non-standard code here?

Thank you,
Kevin Grigorenko
 
V

Victor Bazarov

Kevin Grigorenko said:
I've been using Visual Studio.NET for some time, and I had this
definition of a function in a class:

void throwIt(int id, ErrorType type, ...) throw(...);

There is no exception specification "throw(...)". It's either
"throw()" to state that the function throws _nothing_ or it's
omitted to state that it can throw _anything_.
I am trying to port my code over to linux to work with G++, and I
received this error:

parse error before `...' token

Am I using non-standard code here?

Yes. If you want to claim that your function can/will throw
_anything_, just leave the exception specification out:

void throwIt(int, ErrorType, ...);

Also, make sure your compiler actually understands exception
specifications before attempting to use them.

Victor
 
T

Thierry Miceli

I believe that Visual C++ supports throw(...) following a function
declaration to indicate that the function could throw an exception. Not
standard C++ and it can be removed without altering the program behavior.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top