compiler independent programs

This is a discussion on compiler independent programs within the C++ Programming forums, part of the General Programming Boards category; Hello Could anyone tell me how you make my programs independent of the compiler? I haven't been doing this too ...

  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,831
    >>> 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, 12:32 AM
  3. [resolved] internal compiler error...
    By bling in forum C++ Programming
    Replies: 2
    Last Post: 12-10-2008, 11:57 AM
  4. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 04:42 AM
  5. C Compiler
    By SAMSEIED in forum C Programming
    Replies: 5
    Last Post: 06-06-2002, 05:44 PM

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