Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Will this code work?

Credits go to anonymous, BAF, Billybob, GullRaDriel, Jeff Bernard, StevenVI, Thomas Fjellstrom, Tobias Dammers, and Vanneto for helping out!
This thread is locked; no one can reply to it. rss feed Print
 1   2 
Will this code work?
BAF
Member #2,981
December 2002
avatar

No, that's still not right. Check out the link Audric posted, but anyway, here's your example:

if(crash) FATAL_ERROR;
else printf("okay");

Just using plain {}, that code would turn into:

if(crash) {/*blah*/};
else printf("okay");

... which obviously isn't right.

type568
Member #8,381
March 2007
avatar

And if that would be

#define FATAL_ERROR exit();

It also wouldn't be right, due to the risk of having a:

if(crash) exit();;
else printf("okay");

?

BAF
Member #2,981
December 2002
avatar

Don't put the ; in the define.

Billybob
Member #3,136
January 2003

Thank you for the link to Stack Overflow, that explains everything.

Tobias Dammers
Member #2,604
August 2002
avatar

type568 said:

It compiles.

Doesn't mean sh* with macros.

#define foobar Hello there, you don't know me but I compile! Yay!@@#$%$QWQU

int main() {
  return 0;
}

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Vanneto
Member #8,643
May 2007

There is a difference between just defining a macro and actually using it. :P

In capitalist America bank robs you.

type568
Member #8,381
March 2007
avatar

Well, I did compile it and did put it in to the code(binary code was generated using the Macro) hence your notes seem to be irrelevant.

BAF
Member #2,981
December 2002
avatar

Okay, have fun then. It's not like I'm going to have to deal with your messes... at least I hope not. I'll watch out for you on the daily wtf. 8-)

type568
Member #8,381
March 2007
avatar

:)

 1   2 


Go to: