gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

OffTopic > Merry Christmas!

#32708 - sgeos - Sat Dec 25, 2004 5:22 am

Code:
#include <stdio.h>

/*   if you are offended by the notion of an
 *   xmas post, set this to a non zero value.
 */
#define   OFFENDED_BY_NOTION_OF_XMAS_POST   0

/*   customize your xmas message
 *   maybe you speak a different language =)
 */
#define   MERRY_XMAS_MESSAGE \
   "Merry Christmas everybody!\n"

/*   customize your hello world message
 *   maybe you speak a different language =)
 */
#define   HELLO_WORLD_MESSAGE \
   "Hello world!\n"


int main(void)
{
   if ( ! OFFENDED_BY_NOTION_OF_XMAS_POST )
      printf(MERRY_XMAS_MESSAGE);

   else  /* is OFFENDED_BY_NOTION_OF_XMAS_POST */
      printf(HELLO_WORLD_MESSAGE);

   return 0;
}


-Brendan

#32737 - identitycrisisuk - Sat Dec 25, 2004 2:50 pm

I really wanted there to be some clever way I could optimise that.... ;) Merry Christmas everyone! Thanks for all the help I've received in the short time I've been here.
_________________
Code:
CanIKickIt(YES_YOU_CAN);

#32745 - isildur - Sat Dec 25, 2004 6:38 pm

Merry Xmas to all!

#32754 - DiscoStew - Sat Dec 25, 2004 9:44 pm

Merry Christmas y'all!
_________________
DS - It's all about DiscoStew

#32759 - Lord Graga - Sat Dec 25, 2004 11:29 pm

identitycrisisuk wrote:
I really wanted there to be some clever way I could optimise that.... ;) Merry Christmas everyone! Thanks for all the help I've received in the short time I've been here.


The compiler would actually optimize it :)

#33076 - sgeos - Thu Dec 30, 2004 6:02 pm

identitycrisisuk wrote:
I really wanted there to be some clever way I could optimise that.... ;)

Premature optimization is the root of all evil. -O3 is probably your best bet. If you really want a manual optimisation, try this:
Code:
#if ( ! OFFENDED_BY_NOTION_OF_XMAS_POST )
        printf(MERRY_XMAS_MESSAGE);

#else  /* is OFFENDED_BY_NOTION_OF_XMAS_POST */
        printf(HELLO_WORLD_MESSAGE);

#endif  /* OFFENDED_BY_NOTION_OF_XMAS_POST */


-Brendan