conditional compilation

This is a discussion on conditional compilation within the C Programming forums, part of the General Programming Boards category; I was just reading this other thread about conditional compilation for DOS, or Unix. Well, I understand that the header ...

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    conditional compilation

    I was just reading this other thread about conditional compilation for DOS, or Unix. Well, I understand that the header files are going to be different, but if you compile (let's say in VC in Windows) a console program, you can run it on Unix, right? Because it is already compiled into the executable file. Am I correct? This has always been fuzzy to me. Thanks.

    --Garfield

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > but if you compile (let's say in VC in Windows) a console
    > program, you can run it on Unix, right?

    No. Linux binaries will not run on Windows (and vice versa) without emulation. This is why there are console emulators and such, because the native binaries do not run on other operating systems / hardware.

    Quzah.

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Okay, let me get this straight with a little story:

    I, Garfield, am an aspiring programmer and so is my friend Odie. Garfield uses and programs in Windows. Odie uses and programs in Unix. I call Odie up and tell him that I just wrote this great program and Odie wants it. But, I can't send him the exe because it is platform dependant. So, I have to send him the source code with conditional compilation for him to run it on his Unix system.

    Is this right? Thanks.

    --Garfield

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    > So, I have to send him the source code with conditional compilation for him to run it on his Unix system
    That's the way it's done, yes.

    Basically, anything which isn't ANSI-C will probably need conditional compilation controls around it, so that you get the appropriate code for each platform.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Oh, thanks for the help. Makes sense now. Thanks again.

    --Garfield

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Conditional compilation for object files in Makefile?
    By jutirain in forum C++ Programming
    Replies: 13
    Last Post: 12-19-2007, 05:23 AM
  2. conditional compilation based on existance of a symbol?
    By cyberfish in forum C++ Programming
    Replies: 6
    Last Post: 12-13-2007, 06:35 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Conditional Compilation
    By Peachy in forum C Programming
    Replies: 1
    Last Post: 10-10-2001, 08:54 PM
  5. Preproccessor conditional compilation
    By Garfield in forum C Programming
    Replies: 5
    Last Post: 09-28-2001, 09:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21