Conditional Define

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BQ

    Conditional Define

    Hello

    Is there a way to declare 'FUNCT' via a define so that if its parameter x, a constant, is
    greater than 35, it returns 56, if not, 20.
    I would like that at compile time, not at run time.

    So:

    #define FUNCT(x) x>35?56:20

    is not the answer to my question.
    Could be something like

    #define FUNCT(x) #if (x>35) 56 #else 20 #endif

    Since the 'x' is a constant, this can be done by the preprocessor, so I suppose there's a
    way to do it.

    Maybe it's a stupid question but is there a solution to this issue?
    Thank you in advance,

    Marco Lazzaroni




    ---------------
    El sito de motumboe

    Marco Lazzaroni



  • Joona I Palaste

    #2
    Re: Conditional Define

    BQ <caa_via_sto_to c_balulaz@apoch estolibero.it> scribbled the following:[color=blue]
    > Hello[/color]
    [color=blue]
    > Is there a way to declare 'FUNCT' via a define so that if its parameter x, a constant, is
    > greater than 35, it returns 56, if not, 20.
    > I would like that at compile time, not at run time.[/color]
    [color=blue]
    > So:[/color]
    [color=blue]
    > #define FUNCT(x) x>35?56:20[/color]
    [color=blue]
    > is not the answer to my question.
    > Could be something like[/color]
    [color=blue]
    > #define FUNCT(x) #if (x>35) 56 #else 20 #endif[/color]
    [color=blue]
    > Since the 'x' is a constant, this can be done by the preprocessor, so I suppose there's a
    > way to do it.[/color]
    [color=blue]
    > Maybe it's a stupid question but is there a solution to this issue?
    > Thank you in advance,[/color]

    #if (x>35)
    #define FUNCT(x) 56
    #else
    #define FUNCT(x) 20
    #endif

    Barring some preprocessor syntax errors, you're now in for a "why
    didn't I think of that?" slap on the forehead.

    --
    /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "We're women. We've got double standards to live up to."
    - Ally McBeal

    Comment

    • Allan Bruce

      #3
      Re: Conditional Define


      "BQ" <caa_via_sto_to c_balulaz@APOCH ESTOlibero.it> wrote in message
      news:ph5jc.2264 0$Qc.919215@twi ster1.libero.it ...[color=blue]
      > Hello
      >
      > Is there a way to declare 'FUNCT' via a define so that if its parameter[/color]
      x, a constant, is[color=blue]
      > greater than 35, it returns 56, if not, 20.
      > I would like that at compile time, not at run time.
      >
      > So:
      >
      > #define FUNCT(x) x>35?56:20
      >
      > is not the answer to my question.
      > Could be something like
      >
      > #define FUNCT(x) #if (x>35) 56 #else 20 #endif[/color]

      this is wrong. #XXX are pre-processor defines so do not know anything about
      the values that variables take during execution.
      [color=blue]
      >
      > Since the 'x' is a constant, this can be done by the preprocessor, so I[/color]
      suppose there's a[color=blue]
      > way to do it.[/color]

      No, unless you use a #define for the 'const' you mean.
      [color=blue]
      >
      > Maybe it's a stupid question but is there a solution to this issue?
      > Thank you in advance,
      >
      > Marco Lazzaroni
      >
      >[/color]

      Its not s stupid question, but my immediate response is, why? why doesnt
      x>35?56:20 suffice?
      Allan


      Comment

      • Joona I Palaste

        #4
        Re: Conditional Define

        BQ <caa_via_sto_to c_balulaz@apoch estolibero.it> scribbled the following:[color=blue]
        > Hello[/color]
        [color=blue]
        > Is there a way to declare 'FUNCT' via a define so that if its parameter x, a constant, is
        > greater than 35, it returns 56, if not, 20.
        > I would like that at compile time, not at run time.[/color]
        [color=blue]
        > So:[/color]
        [color=blue]
        > #define FUNCT(x) x>35?56:20[/color]
        [color=blue]
        > is not the answer to my question.
        > Could be something like[/color]
        [color=blue]
        > #define FUNCT(x) #if (x>35) 56 #else 20 #endif[/color]
        [color=blue]
        > Since the 'x' is a constant, this can be done by the preprocessor, so I suppose there's a
        > way to do it.[/color]
        [color=blue]
        > Maybe it's a stupid question but is there a solution to this issue?
        > Thank you in advance,[/color]

        Forget my earlier reply (now cancelled). It used a global variable "x"
        as the parameter in the #if, not the parameter x in the macro itself.
        I don't think what you really want to do is possible at all. Keep in
        mind that the actual value of the argument for your macro isn't known
        until run-time, so #defining it to either 56 or 20 at compile time
        would require clairvoyance.

        --
        /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
        \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
        "I wish someone we knew would die so we could leave them flowers."
        - A 6-year-old girl, upon seeing flowers in a cemetery

        Comment

        • Martin Buchleitner

          #5
          Re: Conditional Define

          * "BQ" <caa_via_sto_to c_balulaz@APOCH ESTOlibero.it> wrote:
          [color=blue]
          > Hello
          >
          > Is there a way to declare 'FUNCT' via a define so that if its parameter x, a constant, is
          > greater than 35, it returns 56, if not, 20.
          > I would like that at compile time, not at run time.
          >
          > So:
          >
          > #define FUNCT(x) x>35?56:20
          >
          > is not the answer to my question.
          > Could be something like
          >
          > #define FUNCT(x) #if (x>35) 56 #else 20 #endif
          >
          > Since the 'x' is a constant, this can be done by the preprocessor, so I suppose there's a
          > way to do it.[/color]


          #if X > 35
          #define result_of_funct 56
          #else
          #defince result_of_fucnt 20
          #endif

          What about that?



          mabu

          --
          Are you Anonymous? Where? ... I don't think so ...

          [ devnull{at}chao sfactory{dot}or g | http://www.chaosfactory.org/ ]

          Comment

          • Nick Landsberg

            #6
            Re: Conditional Define

            Joona I Palaste wrote:
            [color=blue]
            > BQ <caa_via_sto_to c_balulaz@apoch estolibero.it> scribbled the following:
            >[color=green]
            >>Hello[/color]
            >
            >[color=green]
            >>Is there a way to declare 'FUNCT' via a define so that if its parameter x, a constant, is
            >>greater than 35, it returns 56, if not, 20.
            >>I would like that at compile time, not at run time.[/color]
            >
            >[color=green]
            >>So:[/color]
            >
            >[color=green]
            >>#define FUNCT(x) x>35?56:20[/color]
            >
            >[color=green]
            >>is not the answer to my question.
            >>Could be something like[/color]
            >
            >[color=green]
            >>#define FUNCT(x) #if (x>35) 56 #else 20 #endif[/color]
            >
            >[color=green]
            >>Since the 'x' is a constant, this can be done by the preprocessor, so I suppose there's a
            >>way to do it.[/color]
            >
            >[color=green]
            >>Maybe it's a stupid question but is there a solution to this issue?
            >>Thank you in advance,[/color]
            >
            >
            > Forget my earlier reply (now cancelled). It used a global variable "x"
            > as the parameter in the #if, not the parameter x in the macro itself.
            > I don't think what you really want to do is possible at all. Keep in
            > mind that the actual value of the argument for your macro isn't known
            > until run-time, so #defining it to either 56 or 20 at compile time
            > would require clairvoyance.
            >[/color]

            gcc -DX=52 foo.c

            would set the value of X at compile time
            and your original macro's should evaluate properly.
            No? Or is that cheating?




            --
            "It is impossible to make anything foolproof
            because fools are so ingenious"
            - A. Bloch

            Comment

            • BQ

              #7
              Re: Conditional Define


              "Allan Bruce" <allanmb@TAKEAW AYf2s.com> ha scritto nel messaggio
              news:c6inl3$oec $1@news.freedom 2surf.net...[color=blue]
              >[/color]

              [CUT]
              [color=blue][color=green]
              > > So:
              > >
              > > #define FUNCT(x) x>35?56:20
              > >
              > > is not the answer to my question.
              > > Could be something like
              > >
              > > #define FUNCT(x) #if (x>35) 56 #else 20 #endif[/color]
              >
              > this is wrong. #XXX are pre-processor defines so do not know anything about
              > the values that variables take during execution.[/color]

              [CUT]
              [color=blue]
              > Its not s stupid question, but my immediate response is, why? why doesnt
              > x>35?56:20 suffice?
              > Allan[/color]

              Hehe I supposed that I would be generating this kind of questions :-)
              Sorry but I didn't explain clearly enough.
              I'm working on a small microprocessor (and when I say small I mean 32k of ROM and 1536 of
              RAM) so I'm really focused on ROM occupation issues.

              I want to point out anyway that I'd always use FUNCT with a constant defined by a #define.

              x>35?56:20 would generate an 'if' statement that generates relatively a lot of code.
              I suppose that a good compiler substitutes

              if (3>2) 5;

              with

              5

              But it's not my case....

              Marco


              Comment

              • Allan Bruce

                #8
                Re: Conditional Define


                "BQ" <caa_via_sto_to c_balulaz@APOCH ESTOlibero.it> wrote in message
                news:9E5jc.1464 42$Kc3.4860574@ twister2.libero .it...[color=blue]
                >
                > "Allan Bruce" <allanmb@TAKEAW AYf2s.com> ha scritto nel messaggio
                > news:c6inl3$oec $1@news.freedom 2surf.net...[color=green]
                > >[/color]
                >
                > [CUT]
                >[color=green][color=darkred]
                > > > So:
                > > >
                > > > #define FUNCT(x) x>35?56:20
                > > >
                > > > is not the answer to my question.
                > > > Could be something like
                > > >
                > > > #define FUNCT(x) #if (x>35) 56 #else 20 #endif[/color]
                > >
                > > this is wrong. #XXX are pre-processor defines so do not know anything[/color][/color]
                about[color=blue][color=green]
                > > the values that variables take during execution.[/color]
                >
                > [CUT]
                >[color=green]
                > > Its not s stupid question, but my immediate response is, why? why doesnt
                > > x>35?56:20 suffice?
                > > Allan[/color]
                >
                > Hehe I supposed that I would be generating this kind of questions :-)
                > Sorry but I didn't explain clearly enough.
                > I'm working on a small microprocessor (and when I say small I mean 32k of[/color]
                ROM and 1536 of[color=blue]
                > RAM) so I'm really focused on ROM occupation issues.
                >
                > I want to point out anyway that I'd always use FUNCT with a constant[/color]
                defined by a #define.[color=blue]
                >[/color]

                If you are working on that amount of memory, then perhaps ASM is the way to
                go.
                an if statement shouldnt produce lots of code. In a pseudo-asm code.

                CMP x,value ;// compare x with value
                JMPZN;// skip if the status flag of last was negative
                GOTO xxx;// x is greater than value, so goto the given line of execution

                so thats only 3 lines of assembly, which is probably about 6bytes +
                sizeof(int)

                Allan


                Comment

                • Joona I Palaste

                  #9
                  Re: Conditional Define

                  Martin Buchleitner <devnull@chaosf actory.org> scribbled the following:[color=blue]
                  > * "BQ" <caa_via_sto_to c_balulaz@APOCH ESTOlibero.it> wrote:[color=green]
                  >> Hello
                  >>
                  >> Is there a way to declare 'FUNCT' via a define so that if its parameter x, a constant, is
                  >> greater than 35, it returns 56, if not, 20.
                  >> I would like that at compile time, not at run time.
                  >>
                  >> So:
                  >>
                  >> #define FUNCT(x) x>35?56:20
                  >>
                  >> is not the answer to my question.
                  >> Could be something like
                  >>
                  >> #define FUNCT(x) #if (x>35) 56 #else 20 #endif
                  >>
                  >> Since the 'x' is a constant, this can be done by the preprocessor, so I suppose there's a
                  >> way to do it.[/color][/color]
                  [color=blue]
                  > #if X > 35
                  > #define result_of_funct 56
                  > #else
                  > #defince result_of_fucnt 20
                  > #endif[/color]
                  [color=blue]
                  > What about that?[/color]

                  I had the same idea originally, but then I thought that doesn't answer
                  the OP's question. Your preprocessing code will first evaluate a
                  variable X, and then either expand every "result_of_func t" macro to 56,
                  or expand every "result_of_func t" macro to 20. What the OP wants is to
                  evaluate the parameter of result_of_funct macro *SEPARATELY* and expand
                  the macro to either 56 or 20 depending on its value. For example the
                  code:

                  result_of_funct (36); result_of_funct (34);

                  should get expanded to:

                  56; 20;

                  Neither my original code or your code is able to do this.

                  --
                  /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
                  \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
                  "To err is human. To really louse things up takes a computer."
                  - Anon

                  Comment

                  • BQ

                    #10
                    Re: Conditional Define


                    "Allan Bruce" <allanmb@TAKEAW AYf2s.com> ha scritto nel messaggio
                    news:c6ipse$p4n $1@news.freedom 2surf.net...[color=blue]
                    >
                    > "BQ" <caa_via_sto_to c_balulaz@APOCH ESTOlibero.it> wrote in message
                    > news:9E5jc.1464 42$Kc3.4860574@ twister2.libero .it...[color=green]
                    > >
                    > > "Allan Bruce" <allanmb@TAKEAW AYf2s.com> ha scritto nel messaggio
                    > > news:c6inl3$oec $1@news.freedom 2surf.net...[/color][/color]

                    [CUT}]
                    [color=blue]
                    > CMP x,value ;// compare x with value
                    > JMPZN;// skip if the status flag of last was negative
                    > GOTO xxx;// x is greater than value, so goto the given line of execution
                    >
                    > so thats only 3 lines of assembly, which is probably about 6bytes +
                    > sizeof(int)
                    >
                    > Allan
                    >[/color]

                    Allan,
                    the real define I need is used about 500 times in the code, so this would be a large
                    waste of space (and cpu time).

                    In particular, that define is a bit access that is different depending on the location of
                    the byte (near, far) containing the bit I need to test/bit/set.
                    At compile time, I know if that particular byte is in near or in far memory.

                    Having defined

                    typedef struct {
                    unsigned b0:1;
                    unsigned b1:1;
                    unsigned b2:1;
                    unsigned b3:1;
                    unsigned b4:1;
                    unsigned b5:1;
                    unsigned b6:1;
                    unsigned b7:1;
                    } BOOL;

                    and

                    #define BIT(byte,bit) (*((BOOL*)&byte )).bit

                    Where bit can be b0,b1,b2...b7.

                    And so I can access a bit in the memory.
                    Compiling it, I get 2 ASM instructions.
                    Anyway if I use this definition, valid only for near memory:

                    #define BIT(byte,bit) (*((near BOOL*)&byte)).b it

                    ....I would get 1 single ASM instruction.


                    So, provided that I have a way to determine AT COMPILE TIME if I am able to use this
                    second define (and I can) (let call this macro ISNEAR(byte)),
                    I would like to write something like this:

                    #define BIT(byte,bit) #if ISNEAR(byte) ( (*((near BOOL*)&byte)).b it ) #else (
                    (*((BOOL*)&byte )).bit ) #endif

                    Regards,

                    Marco


                    Comment

                    • BQ

                      #11
                      Re: Conditional Define


                      "Joona I Palaste" <palaste@cc.hel sinki.fi> ha scritto nel messaggio
                      news:c6iskt$ptq $1@oravannahka. helsinki.fi...[color=blue]
                      > Martin Buchleitner <devnull@chaosf actory.org> scribbled the following:[color=green]
                      > > * "BQ" <caa_via_sto_to c_balulaz@APOCH ESTOlibero.it> wrote:[/color][/color]

                      [CUT]
                      [color=blue]
                      > I had the same idea originally, but then I thought that doesn't answer
                      > the OP's question. Your preprocessing code will first evaluate a
                      > variable X, and then either expand every "result_of_func t" macro to 56,
                      > or expand every "result_of_func t" macro to 20. What the OP wants is to
                      > evaluate the parameter of result_of_funct macro *SEPARATELY* and expand
                      > the macro to either 56 or 20 depending on its value. For example the
                      > code:
                      >
                      > result_of_funct (36); result_of_funct (34);
                      >
                      > should get expanded to:
                      >
                      > 56; 20;[/color]

                      Thank you Joona, this is *exactly* what I meant (and what I need in my code).
                      I'm concerned about that fact that this can be determined at compile time, so I suppose
                      that there must be a way to do what I need.

                      Maybe that

                      #define FUNCT(x) #if (x>35) 56 #else 20 #endif

                      has problems because it needs two passes of the preprocessor (one in which it substitutes
                      each instance of 'FUNCT', one in which the preprocessor solves the #if clause).

                      Regards,

                      Marco Lazzaroni


                      Comment

                      • Joona I Palaste

                        #12
                        Re: Conditional Define

                        BQ <caa_via_sto_to c_balulaz@apoch estolibero.it> scribbled the following:[color=blue]
                        > "Joona I Palaste" <palaste@cc.hel sinki.fi> ha scritto nel messaggio
                        > news:c6iskt$ptq $1@oravannahka. helsinki.fi...[color=green]
                        >> Martin Buchleitner <devnull@chaosf actory.org> scribbled the following:[color=darkred]
                        >> > * "BQ" <caa_via_sto_to c_balulaz@APOCH ESTOlibero.it> wrote:[/color][/color][/color]
                        [color=blue]
                        > [CUT][/color]
                        [color=blue][color=green]
                        >> I had the same idea originally, but then I thought that doesn't answer
                        >> the OP's question. Your preprocessing code will first evaluate a
                        >> variable X, and then either expand every "result_of_func t" macro to 56,
                        >> or expand every "result_of_func t" macro to 20. What the OP wants is to
                        >> evaluate the parameter of result_of_funct macro *SEPARATELY* and expand
                        >> the macro to either 56 or 20 depending on its value. For example the
                        >> code:
                        >>
                        >> result_of_funct (36); result_of_funct (34);
                        >>
                        >> should get expanded to:
                        >>
                        >> 56; 20;[/color][/color]
                        [color=blue]
                        > Thank you Joona, this is *exactly* what I meant (and what I need in my code).
                        > I'm concerned about that fact that this can be determined at compile time, so I suppose
                        > that there must be a way to do what I need.[/color]

                        Suppose your code has something like:
                        int x;
                        scanf("%d", &x);
                        result_of_funct (x);
                        In order to expand the macro at compile time to 56 or 20, the compiler
                        would have to be able to see into the future to know what value the user
                        will enter. And if the program is going to be run more than once, with
                        different inputs typed by the user, then the only way to expand the
                        macro at compile time is to split the universe into two parallel
                        dimensions, each with their own version of the program and the user
                        input.
                        I suppose that is enough to let you know that a macro definition like
                        what you ask for is inherently impossible at compile time?
                        [color=blue]
                        > Maybe that[/color]
                        [color=blue]
                        > #define FUNCT(x) #if (x>35) 56 #else 20 #endif[/color]
                        [color=blue]
                        > has problems because it needs two passes of the preprocessor (one in which it substitutes
                        > each instance of 'FUNCT', one in which the preprocessor solves the #if clause).[/color]

                        The preprocessor is a one-pass device. You cannot create new
                        preprocessing instructions with macros unless you plan to compile your
                        source multiple times.

                        --
                        /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
                        \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
                        "The large yellow ships hung in the sky in exactly the same way that bricks
                        don't."
                        - Douglas Adams

                        Comment

                        • BQ

                          #13
                          Re: Conditional Define


                          "Joona I Palaste" <palaste@cc.hel sinki.fi> ha scritto nel messaggio
                          news:c6j05j$scs $1@oravannahka. helsinki.fi...
                          [CUT]
                          [color=blue]
                          > I suppose that is enough to let you know that a macro definition like
                          > what you ask for is inherently impossible at compile time?[/color]

                          I agree with you.
                          But my issue is different (I believe).
                          Let say I have

                          #define A 100
                          #define B 0

                          #define FUNCT(x) #if (x>35) 56 #else 20 #endif /*a working version of it ;-) */

                          (...)

                          int main(....
                          {
                          .....
                          int c,d;

                          c=A; //should be c=56
                          d=B; //should be d=20;
                          }


                          This doesn't require knowledge of the future and can be safely expanded by the
                          preprocessor with:

                          .....
                          c=56;
                          d=20;
                          .....

                          [color=blue][color=green]
                          > > Maybe that[/color]
                          >[color=green]
                          > > #define FUNCT(x) #if (x>35) 56 #else 20 #endif[/color]
                          >[color=green]
                          > > has problems because it needs two passes of the preprocessor (one in which it[/color][/color]
                          substitutes[color=blue][color=green]
                          > > each instance of 'FUNCT', one in which the preprocessor solves the #if clause).[/color]
                          >
                          > The preprocessor is a one-pass device. You cannot create new
                          > preprocessing instructions with macros[/color]

                          So I suppose I'll finish writing a small pre-preprocessor ... doh!
                          [color=blue]
                          > unless you plan to compile your
                          > source multiple times.[/color]

                          Great! How can this be done?

                          Regards,

                          Marco Lazzaroni


                          Comment

                          • Case

                            #14
                            Re: Conditional Define

                            BQ wrote:[color=blue]
                            > Hello
                            >
                            > Is there a way to declare 'FUNCT' via a define so that if its parameter x, a constant, is
                            > greater than 35, it returns 56, if not, 20.
                            > I would like that at compile time, not at run time.
                            >
                            > So:
                            >
                            > #define FUNCT(x) x>35?56:20
                            >
                            > is not the answer to my question.
                            > Could be something like
                            >
                            > #define FUNCT(x) #if (x>35) 56 #else 20 #endif
                            >
                            > Since the 'x' is a constant, this can be done by the preprocessor, so I suppose there's a
                            > way to do it.
                            >
                            > Maybe it's a stupid question but is there a solution to this issue?
                            > Thank you in advance,[/color]

                            I've read the discussion so far. I think your problem might
                            be solved by compiler optimization. Most modern compiler will
                            not generate any if-instructions for code like: 3 ? 23 : 20.
                            Also, many compilers have the ability to leave out never reached
                            code. So for

                            if (NEAR(0x1234))
                            FUNCT_NEAR(.... );
                            else
                            FUNCT(.....);

                            only code for one of the two branches *could* be generated given
                            that NEAR(0x1234) can be evaluated at compiler (or sometimes even
                            link time).

                            Does this help?

                            Kees

                            Comment

                            • Joona I Palaste

                              #15
                              Re: Conditional Define

                              BQ <caa_via_sto_to c_balulaz@apoch estolibero.it> scribbled the following:[color=blue]
                              > "Joona I Palaste" <palaste@cc.hel sinki.fi> ha scritto nel messaggio
                              > news:c6j05j$scs $1@oravannahka. helsinki.fi...
                              > [CUT][/color]
                              [color=blue][color=green]
                              >> I suppose that is enough to let you know that a macro definition like
                              >> what you ask for is inherently impossible at compile time?[/color][/color]
                              [color=blue]
                              > I agree with you.
                              > But my issue is different (I believe).
                              > Let say I have[/color]
                              [color=blue]
                              > #define A 100
                              > #define B 0[/color]
                              [color=blue]
                              > #define FUNCT(x) #if (x>35) 56 #else 20 #endif /*a working version of it ;-) */[/color]
                              [color=blue]
                              > (...)[/color]
                              [color=blue]
                              > int main(....
                              > {
                              > ....
                              > int c,d;[/color]
                              [color=blue]
                              > c=A; //should be c=56
                              > d=B; //should be d=20;
                              > }[/color]
                              [color=blue]
                              > This doesn't require knowledge of the future and can be safely expanded by the
                              > preprocessor with:[/color]
                              [color=blue]
                              > ....
                              > c=56;
                              > d=20;
                              > ....[/color]

                              You know that, I know that, but C compilers don't. The compilers aren't
                              intelligent enough to think "outside of the box" and see that the above
                              code can be handled without knowledge of run-time operations. So what
                              you want is still impossible with the current version of C.
                              [color=blue][color=green][color=darkred]
                              >> > Maybe that[/color]
                              >>[color=darkred]
                              >> > #define FUNCT(x) #if (x>35) 56 #else 20 #endif[/color]
                              >>[color=darkred]
                              >> > has problems because it needs two passes of the preprocessor (one in which it[/color][/color]
                              > substitutes[color=green][color=darkred]
                              >> > each instance of 'FUNCT', one in which the preprocessor solves the #if clause).[/color]
                              >>
                              >> The preprocessor is a one-pass device. You cannot create new
                              >> preprocessing instructions with macros[/color][/color]
                              [color=blue]
                              > So I suppose I'll finish writing a small pre-preprocessor ... doh![/color]
                              [color=blue][color=green]
                              >> unless you plan to compile your
                              >> source multiple times.[/color][/color]
                              [color=blue]
                              > Great! How can this be done?[/color]

                              It's a bit difficult. I'm not sure myself how to do it. I had in mind
                              first preprocessing your code into an intermediate version and then
                              preprocessing it again. I don't know if there's a way to compile the
                              normal parts first and the preprocessed parts later.

                              --
                              /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
                              \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
                              "Insanity is to be shared."
                              - Tailgunner

                              Comment

                              Working...