How to differentiate between ubuntu and redhat using c preprocessor ?

Discussion in 'Ubuntu' started by Zeno, Jul 26, 2012.

  1. Zeno

    Zeno New Member

    Joined:
    Jul 26, 2012
    Messages:
    2
    Likes Received:
    0
    Hi,

    I am a newbie to C programming, I am writing a cross platform C code. Is there any C preprocessor to differentiate between Ubuntu and RedHat Linux Distros?

    Is there any other way I can do this?


    Thanks in Advance.
     
  2. Akendo

    Akendo New Member

    Joined:
    Feb 12, 2012
    Messages:
    135
    Likes Received:
    7
    Hi Zeno,

    Welcome to the LinuxForum.

    In every Linux your using the GNU Compiler Collection (Wikipedia:gcc). The only different is sometime where there are locates as file itself. Redhat sometime (or Ubuntu/Debian). But this should not matter.

    But Redhat uses always the older and stable releases of the gcc. So when your develop with something new you can't expect working in Redhat by default.


    Hopefully this was helpful.

    so far
    Akendo
     
    Zeno likes this.
  3. Theophrastus

    Theophrastus New Member

    Joined:
    Jul 26, 2012
    Messages:
    1
    Likes Received:
    0
    some combination of this sort of maneuver may accomplish that:
    gcc "-DCOMPILED_ON=\"`uname -a`\"" -c file.c -o file.o

    see:
    for some odd reason i'm not seeing how i can be permitted to include a useful link to this approach perhaps if i mangle the link i can get it through: "http:" + // +
    stackoverflow.com/questions/5319289/can-the-gcc-c-preprocessor-use-the-output-of-a-shell-command
     
  4. Zeno

    Zeno New Member

    Joined:
    Jul 26, 2012
    Messages:
    2
    Likes Received:
    0
    Could you please suggest me how this can be done.
     

Share This Page