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
      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
    • guy keren
      ... i don t think it matters - it is better to use commonly-used tools, then to fetch some rare tool that ll now be required on the compilation machine. using
      Message 2 of 9 , Apr 29, 2005
        On Fri, 29 Apr 2005, Omer Zak wrote:

        > Is there another text files preprocessing tool, which knows to process
        > file inclusion directives before executing them?

        i don't think it matters - it is better to use commonly-used tools, then
        to fetch some rare tool that'll now be required on the compilation
        machine. using the tools already found on the system is better for things
        that they can easily do.

        --
        guy

        "For world domination - press 1,
        or dial 0, and please hold, for the creator." -- nob o. dy
      • 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 3 of 9 , Apr 29, 2005
          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 4 of 9 , Apr 30, 2005
            --- 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 5 of 9 , Apr 30, 2005
              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.