defining a catch statement with #define

  • Thread starter Thread starter DaTurk
  • Start date Start date
D

DaTurk

Hi, I want to define a very large catch clause in a pound define.
I've done this, and it compiles, but when I try to incorporate it into
the code I'm having issues.

#define CATCH_THING{
catch(Exception ^ ex) \
{ \
<Do Something> \
}\
}

try
{
<Some Code>
}
CATCH_THING

What am I doing wrong?
 
Hi, I want to define a very large catch clause in a pound define.
I've done this, and it compiles, but when I try to incorporate it into
the code I'm having issues.

#define CATCH_THING{
catch(Exception ^ ex) \
{ \
<Do Something> \

}\
}

try
{
<Some Code>}

CATCH_THING

What am I doing wrong?

It doesn't compile for me as supplied. Why not this:

#define CATCH_THING \
catch(Exception ^ ex) \
{ \
<Do Something> \

}\
 
Sorry, I just wrote it off the cuff. Here's something that is exactly
in my code

#define EXCEPTION_HANDLING { \
catch(Exception^ uEx) \
{ \
throw uEx; \
} \
}

my problem is that, although this compiles, I can't seem to get this
to work with the try block.

try
{

}
EXCEPTION_HANDLING

??
I keep getting the error that the try doesn't hav a catch.
 
DaTurk said:
Sorry, I just wrote it off the cuff. Here's something that is exactly
in my code

#define EXCEPTION_HANDLING { \
catch(Exception^ uEx) \
{ \
throw uEx; \
} \
}

my problem is that, although this compiles, I can't seem to get this
to work with the try block.

try
{

}
EXCEPTION_HANDLING

??
I keep getting the error that the try doesn't hav a catch.

You have an extra set of {. Your macro expands the above to

try
{
}
{ <-- get rid of this
catch(Exception^ uEx)
{
}
} <-- and this

-cd
 
You have an extra set of {. Your macro expands the above to

try
{}

{ <-- get rid of this
catch(Exception^ uEx)
{
}

} <-- and this

-cd- Hide quoted text -

- Show quoted text -

Awesome, that did the trick. THank you
 
Back
Top