problem with /define in VAX C: help!

mlevin at jade.tufts.edu mlevin at jade.tufts.edu
Thu Jun 20 13:01:47 AEST 1991


  I have the following problem. I want to do conditional compilation,
based on the value of a variable given at compile time. On a Unix
system, if I have the program:

main()
{
  enum {AA, BB, CC} dd;
  dd = DEF;
#if DEF!=CC
  printf("%d\n",dd);
#endif
}

  And I compile it with: "cc a.c -DDEF=BB", the program will print out
1 when it runs, because DEF is assigned the enum value BB, which is
not equal to the enum value CC, so the printf goes in. But, on a VMS
system with Vax C, when I do cc a.c /define="DEF=BB", the printf is
never put in. I think it is because the compiler thinks DEF and CC are
both undefined at the point of the #if, assigns them both to 0, and
they are thus always equal (so the printf never gets put in). Am I
missing something (as usual)? Or is this a genuine difference between
Unix and Vax C compilers? In any case, I'd appreciate any help on how
I can do this in Vax C: I need to pass in an enum value during
compile-time. Please direct all suggestions to mlevin at jade.tufts.edu.

Mike Levin




More information about the Comp.lang.c mailing list