C++: compile time conditional inheritance

From: Doru-Catalin Togea (doru-cat_at_ifi.uio.no)
Date: 02/14/04


Date: Sat, 14 Feb 2004 17:58:34 +0100

Hi!

I'm using Redhat 9.0 with GCC 3.2.

I have three classes which all implement different kinds of "Module"
objects.

In my application I have objects which must inherit any ONE of the Module
classes.

How do I tell the compiler how to chose a particular class at compile
time? My goal is to be able to easily build the application with objects
based on any of the available Module classes.

Say I have classA, classB and classC. I'm thinking that maybe by declaring
an environment variable and setting its value to say "A", "B" or "C" I
could direct my compilation to link in the right class. Or can I get the
job done with only "#ifdef"s?

I want to easily make the compiler see either

class MyObject : public classA {...}; or
class MyObject : public classB {...}; or
class MyObject : public classC {...};

without having to change programme code.

Thanks if anyone can help.
Catalin

-- 
        <<<< ================================== >>>>
        <<     We are what we repeatedly do.      >>
        <<  Excellence, therefore, is not an act  >>
        <<             but a habit.               >>
        <<<< ================================== >>>>


Relevant Pages

  • Re: Free C Compiler on Windows
    ... contract of software maintenance with gcc with RedHat for 25 000 ... I'm not sure that GNU and Redhat are synonomous terms but you ... You are ALSO a "vendor" then. ... I'm impressed with anyone that implements a full compiler and if you ...
    (comp.lang.c)
  • Re: C90 penetration
    ... The computers in my automobile engine, for example, ... C that was compiled by a free compiler. ... across so far were targetable by GCC. ... Redhat and Redhat kind of destroyed them. ...
    (comp.lang.c)
  • Re: GCC 2.96 and "-march=i686"
    ... >> RedHat never claimed this is release from GCC team. ... Reason may be bug in your code, or in compiler, ...
    (comp.unix.programmer)
  • Re: Recent exploits: whats with Redhat?!?
    ... I hope RedHat will admit that. ... the only problem with 7.0 was the choice of using a gcc prepatch. ... still you can always install your own compiler. ... readily make either of them your default compiler. ...
    (comp.os.linux.security)
  • Re: Whats the story with the "end of XP"?
    ... Support gives them access to the larger body ... The same compiler suite may be "best" in both ... In the case of ByteCraft compilers, you are truly expert in your field, you work closely and rapidly with customers if there are any issues, and you have top class testing and quality control. ... understanding the inner workings of a relatively simple compiler like GCC ...
    (comp.arch.embedded)