Loading ...
Sorry, an error occurred while loading the content.

Re: [hackers-il] Pattern for building several variants of a software module

Expand Messages
  • Oleg Goldshmidt
    ... But A can contain #ifdef FIRST_VARIANT #include C1 #endif #ifdef SECOND_VARIANT #include C2 #endif etc, can t it? -- Oleg Goldshmidt |
    Message 1 of 9 , Apr 29, 2005
    • 0 Attachment
      Omer Zak <omerz@...> writes:

      > Since cpp does not process macros inside #include statements, and so I
      > cannot pass to it a filename using the -D flag, I need another way to
      > modify file A for each version of file C.

      But A can contain

      #ifdef FIRST_VARIANT
      #include "C1"
      #endif

      #ifdef SECOND_VARIANT
      #include "C2"
      #endif

      etc, can't it?


      --
      Oleg Goldshmidt | pub@... | http://www.goldshmidt.org
    • Omer Zak
      ... This can work, but requires me to modify both the makefile and A if I want to add another variant of file C (when I want to build a file from A and its
      Message 2 of 9 , Apr 29, 2005
      • 0 Attachment
        On Fri, 2005-04-29 at 11:12 +0000, Oleg Goldshmidt wrote:
        > Omer Zak <omerz@...> writes:
        >
        > > Since cpp does not process macros inside #include statements, and so I
        > > cannot pass to it a filename using the -D flag, I need another way to
        > > modify file A for each version of file C.
        >
        > But A can contain
        >
        > #ifdef FIRST_VARIANT
        > #include "C1"
        > #endif
        >
        > #ifdef SECOND_VARIANT
        > #include "C2"
        > #endif
        >
        > etc, can't it?
        >

        This can work, but requires me to modify both the makefile and A if I
        want to add another variant of file C (when I want to build a file from
        A and its #include'd files, and C - one of its #include'd files - has
        several variants, and I want to build a separate file from A with each
        variant of C).

        An elegant way would allow me to modify only the makefile to add another
        variant of C (or just drop in the additional C variant, if I use GNU
        make's $(wildcard PATTERN) feature).
        --- Omer
        --
        MS-Windows is the Pal-Kal of the PC world.
        My own blog is at http://www.livejournal.com/users/tddpirate/

        My opinions, as expressed in this E-mail message, are mine alone.
        They do not represent the official policy of any organization with which
        I may be affiliated in any way.
        WARNING TO SPAMMERS: at http://www.zak.co.il/spamwarning.html
      • Omer Shapira
        ... ... What about placing all platform-specific headers into directories under role-based names (./x86-64/types.h,
        Message 3 of 9 , Apr 30, 2005
        • 0 Attachment
          --- Omer Zak <omerz@...> wrote:
          <!-- abridged -->
          > An elegant way would allow me to modify only the
          > makefile to add another
          > variant of C (or just drop in the additional C
          > variant, if I use GNU
          > make's $(wildcard PATTERN) feature).
          <!-- abridged -->

          What about placing all platform-specific headers into
          directories under role-based names (./x86-64/types.h,
          ./ppc604/types.h ./ppc7410/types.h) and factor the
          include path into the Makefile?

          Clients of these platform dependent classes will
          reference only the role name ( #include <types.h>).

          > --- Omer
          > --
          <!-- bandwidth saved by XML comment -->

          o.s.


          --
          Omer Shapira
          Senior Software Engineer
          Radware

          __________________________________________________
          Do You Yahoo!?
          Tired of spam? Yahoo! Mail has the best spam protection around
          http://mail.yahoo.com
        • Oleg Goldshmidt
          ... Strictly speaking, no - you can do make VARIANT=FIRST_VARIANT at invocation time. Frankly, I don t understand what you are trying to achieve here. All the
          Message 4 of 9 , Apr 30, 2005
          • 0 Attachment
            Omer Zak <omerz@...> writes:

            > This can work, but requires me to modify both the makefile and A if I
            > want to add another variant of file C (when I want to build a file from
            > A and its #include'd files, and C - one of its #include'd files - has
            > several variants, and I want to build a separate file from A with each
            > variant of C).

            Strictly speaking, no - you can do

            make VARIANT=FIRST_VARIANT

            at invocation time.

            Frankly, I don't understand what you are trying to achieve here. All
            the variants starting from your own seem workable to me. Take a look
            at /usr/include/features.h for inspiration?

            --
            Oleg Goldshmidt | pub@... | http://www.goldshmidt.org
          Your message has been successfully submitted and would be delivered to recipients shortly.