Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2007

Tip: Looking for answers? Try searching our database.

defining a catch statement with #define

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DaTurk - 22 Jun 2007 17:16 GMT
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?
kelvin.koogan@googlemail.com - 22 Jun 2007 17:57 GMT
> 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
[quoted text clipped - 15 lines]
>
> What am I doing wrong?

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

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

}\
DaTurk - 22 Jun 2007 18:07 GMT
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.
Carl Daniel [VC++ MVP] - 22 Jun 2007 20:11 GMT
> Sorry, I just wrote it off the cuff.  Here's something that is exactly
> in my code
[quoted text clipped - 17 lines]
> ??
> 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
DaTurk - 22 Jun 2007 21:48 GMT
On Jun 22, 2:11 pm, "Carl Daniel [VC++ MVP]"
<cpdaniel_remove_this_and_nos...@mvps.org.nospam> wrote:

> > Sorry, I just wrote it off the cuff.  Here's something that is exactly
> > in my code
[quoted text clipped - 33 lines]
>
> - Show quoted text -

Awesome, that did the trick.  THank you

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.