News for hackers. Stuff that matters.
Re:Wikileaks To Leak 5000 Open Source Java Projects by jmatt on Wednesday July 28, 2010 @07:47PM (#1556048)
continued "fun" (read dangerous) redefines:

  #define true false
  #define false true

  #define true 0
  #define false !true

  #define if while
  #define continue break
:)
Re:Wikileaks To Leak 5000 Open Source Java Projects by shasta on Wednesday July 28, 2010 @11:23PM (#1556521)

  #define true false
  #define false true
Did you know that if you do both of those, they cancel each other out? True story.
Re:Wikileaks To Leak 5000 Open Source Java Projects by troels on Thursday July 29, 2010 @04:05AM (#1556942)
My head hurts. Explanation, please?
Re:Wikileaks To Leak 5000 Open Source Java Projects by shasta on Thursday July 29, 2010 @08:39AM (#1557358)
There's a rule in the preprocessor to prevent infinite recursion: only replace each symbol once. The first time it encounters 'true', it's replaced with 'false'. The first time it encounters 'false, it's replace with 'true'. It's already seen 'true', so it throws up its hands.

The consequence of this rule is that cycles of #defines don't do anything. Edit: Well, that's only true if there aren't other symbols introduced during expansion. Here's a counterexample that prints 3:

   #include <stdio.h>

   int x = 1;

   #define x 1 + y
   #define y 1 + x

   int main(int argc, char *argv[])
   {
     printf("%d\n",x);
     return 0;
   }
Re:Wikileaks To Leak 5000 Open Source Java Projects by troels on Thursday July 29, 2010 @09:04AM (#1557410)
Ah .. Makes sense. Thanks.
Re:Wikileaks To Leak 5000 Open Source Java Projects by malkia on Thursday July 29, 2010 @04:10AM (#1556952)
Dunno about explanation, but experiment shows it to work at least with two preprocessors - Microsoft's and GCC:

First make a file a.c that has in it:

#define true false

#define false true

int A = true;

int B = false;

then from the command line, do (with the Microsoft compiler): D:\>cl -E a.c

int A = true;

int B = false;

Now with gcc (I'm using cygwin's gcc): D:\>sh -c "gcc -E a.c"

int A = true;

int B = false;

I've stripped the other stuff.

Re:Wikileaks To Leak 5000 Open Source Java Projects by VeXocide on Thursday July 29, 2010 @02:58AM (#1556846)

  #define TRUE random()%2
Re:Wikileaks To Leak 5000 Open Source Java Projects by rjurney on Thursday July 29, 2010 @03:59AM (#1556936)
You are truly devious
Re:Wikileaks To Leak 5000 Open Source Java Projects by chaosgame on Wednesday July 28, 2010 @08:23PM (#1556121)
#define struct union
Re:Wikileaks To Leak 5000 Open Source Java Projects by moultano on Wednesday July 28, 2010 @10:26PM (#1556397)
That is by far the evilest of the bunch. }:-D