Thread: compiler independent programs

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    23

    Question compiler independent programs

    Hello

    Could anyone tell me how you make my programs independent of the compiler?

    I haven't been doing this too long but none of the programs I have made work unless opened with MS Visual C++ 6 which is what I used to make them.

    Any clues?

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Unfortuneately what you want is nigh on imposssible. I do not know of any compiler that is fully ANSI compliant. Every compiler has its quirks. You can program in ANSI c++ and at best hope that your code will compile on other compilers without changes.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> I do not know of any compiler that is fully ANSI compliant.

    Ain't that the truth!
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User Liam Battle's Avatar
    Join Date
    Jan 2002
    Posts
    114
    well if you want to write code to work on multipul compilers and platforms, then you have to put precompiler statements saying which one is going to be compiled. ie:

    #define UNIX 2
    #define MSVC 1
    #define BORLAND 3

    #define PLATFORM = UNIX

    #if PLATFORM == MSVC
    //.. DO SOME CODE
    #endif

    #if PLATFORM == UNIX
    //.. do some code
    #endif

    #if PLATFORM == BORLANDC
    //.. do some code
    #endif


    if you compiled it then it would invoke only the UNIX code when it sends through the pre-processor.

    hope that answers your question

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Which Compiler?
    By Bladactania in forum C Programming
    Replies: 10
    Last Post: 02-11-2009, 01:32 AM
  3. [resolved] internal compiler error...
    By bling in forum C++ Programming
    Replies: 2
    Last Post: 12-10-2008, 12:57 PM
  4. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 05:42 AM
  5. C Compiler
    By SAMSEIED in forum C Programming
    Replies: 5
    Last Post: 06-06-2002, 05:44 PM