Like Tree2Likes
  • 1 Post By laserlight
  • 1 Post By jcfuller

c++ standards, portability

This is a discussion on c++ standards, portability within the C++ Programming forums, part of the General Programming Boards category; which standard of c++ (c++0x, c++3, c++11) is the most portable (across other compilers)? i read that visual c++ doesn't ...

  1. #1
    hit
    hit is offline
    Registered User
    Join Date
    Aug 2012
    Posts
    11

    c++ standards, portability

    which standard of c++ (c++0x, c++3, c++11) is the most portable (across other compilers)?

    i read that visual c++ doesn't fully support c++11, but gcc does.

    in C i only used c89 for portability, which should i use in c++, or does it not matter?

    I like to use visual c++ on windows, and codeblocks (gcc) on linux. I like to have my code portable between both OSes & compilers

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    C++0x and C++11 refer to the same edition of the standard. The "0x" was just short hand for "we think it is going to be published in '08 or '09, but we don't know yet... oh, it was published in '0B!".

    Anyway, if you need your code to be compilable on compilers (and standard library implementations) that fall well short of implementing C++11, then just write your code with respect to C++03.
    Matticus likes this.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,145
    O_o

    I'd go with C++03 as well. (Well, C++98 as C++03 is basically just a "bug fix".)

    If you have at least "GCC 4.0" or "Microsoft Visual C++ 2003" and higher you'll have a very large C++03 surface area to hit. There is really very few corners cases where you'd need hacks to provide that portability.

    You can proof forward to some of the C++11 features by using the "Boost" library if you need some of those library features.

    [Edit]
    The "Boost" library is extremely portable in that the implements have targeted an enormous number of bugs with hundreds of fixes.
    [/Edit]

    Soma

  4. #4
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    902
    I don't know of any current commercial compiler that doesn't support C99 and C++03. Where I work, we won't be adopting C++11/14 for a few years since some of our platforms' compiler vendors won't support it for a while. C++03 is a sure bet in my experience, though. Also, I've never had trouble getting access to C99 features either (the fixed-size integer types interest me, mostly).
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    2,675
    I don't know of any current commercial compiler that doesn't support C99
    I know of one, Microsoft C is not C99 compatible, and probably never will be.

    Their C++ compiler does support most of C++11 and they seem to be moving towards complete compliance of this standard.

    Jim

  6. #6
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    902
    Ah, true. I've been spoiled writing for Unix-like environments.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  7. #7
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,145
    Their C++ compiler does support most of C++11 and they seem to be moving towards complete compliance of this standard.
    O_o

    Well, things may have changed, and I certainly hope that is the case, but last I checked, Microsoft was still more or less sticking to "We have no intention of ever supporting some C++11 features.", but they also said the same thing about variadic templates which has been available for a few months.

    Soma

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    Quote Originally Posted by jimblumberg View Post
    Their C++ compiler does support most of C++11 and they seem to be moving towards complete compliance of this standard.
    Far from it. They have an essentially complete standard library without constexpr and initializer list support, but the number of core language features missing is staggering, and they seem unwilling to pump any more any time soon, as indicated by their silence. They did promise incremental updates to the compiler, but we have yet to see that.
    We'll see how things turn out in VC12.

    Of course, mingw and clang are both available on Windows, and they have pretty much full C++11 support and are moving towards starting implementation of C++14.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,288
    Quote Originally Posted by Elysia View Post
    Of course, mingw and clang are both available on Windows, and they have pretty much full C++11 support and are moving towards starting implementation of C++14.
    Clang? Available on Windows!?!
    That's still in the rather experimental stage. As far as I can see, you either have to go to a lot of trouble to download and install various tools and build the compiler yourself!, or you have to have something that unzips .gz files, and other messing around whilst having very limited options in terms of any support. And of course there's no x64 support yet.
    It's hardly a realistic option for the typical programmer at this point.

    As for mingw, unless you are adept at makefiles (I wouldn't waste my time with such primitive stuff), you pretty much need to install codeblocks, which came with a rather outdated version of mingw last time I checked.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  10. #10
    Registered User
    Join Date
    Jul 2008
    Posts
    35
    Quote Originally Posted by iMalc View Post
    As for mingw, unless you are adept at makefiles (I wouldn't waste my time with such primitive stuff), you pretty much need to install codeblocks, which came with a rather outdated version of mingw last time I checked.
    CMake has support for MinGW. And besides Codeblocks, there is also Netbeans/Eclipse.

  11. #11
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    Quote Originally Posted by iMalc View Post
    Clang? Available on Windows!?!
    That's still in the rather experimental stage. As far as I can see, you either have to go to a lot of trouble to download and install various tools and build the compiler yourself!, or you have to have something that unzips .gz files, and other messing around whilst having very limited options in terms of any support. And of course there's no x64 support yet.
    It's hardly a realistic option for the typical programmer at this point.

    As for mingw, unless you are adept at makefiles (I wouldn't waste my time with such primitive stuff), you pretty much need to install codeblocks, which came with a rather outdated version of mingw last time I checked.
    Depends on your needs, really.
    But sure, there are prebuilt binaries for clang for windows, and it's not tricky to get it working at all (if you do it right; I can imagine it being tough for a newbie who has no idea where to look).
    And again, correct me if I'm wrong, but you can just manually install mingw and set up codeblocks to use it. Not ideal for a newbie, but it works.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,288
    Quote Originally Posted by Elysia View Post
    And again, correct me if I'm wrong, but you can just manually install mingw and set up codeblocks to use it. Not ideal for a newbie, but it works.
    I read a thread on, hmm stackoverflow I think it was, not so long ago, where someone had done exactly that, and the consensus about the problems they were having was due to an incompatibility between the mingw version and codeblocks.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  13. #13
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,145
    I read a thread on, hmm stackoverflow I think it was, not so long ago, where someone had done exactly that, and the consensus about the problems they were having was due to an incompatibility between the mingw version and codeblocks.
    O_o

    Well, the people saying that didn't know what they were talking about.

    Yes, different distributions of "MinGW" may have different directories to include or the individual distributing the binary may have failed to get the relative positioning installed correctly, but the primary options which the "CodeBlocks" "GCC" plugin would use haven't changed in a long time.

    Problems such as those aren't related to an incompatibility between "CodeBlocks" and "MinGW"; such problems are born of the individuals distributing binaries not doing the job properly.

    These directories all point to "CC1.exe" without which compiling just does not happen:

    Code:
    libexec\gcc\mingw32\4.6.1
    Code:
    libexec\gcc\i686-pc-mingw32\4.7.1
    Code:
    libexec\gcc\4.8.0
    Code:
    libexec\gcc\i686-pc-mingw32\4.8.1
    None of these distributions have properly enabled relative positioning so if these directories aren't part of the "Path" environment variable compilation fails.

    You have to add such paths to "CodeBlocks" manually, and that's just one issue; several other required files like "crtbegin.o", "libgcc.a", and "sup/bits/*" also live in different directories for these distributions.

    The setup can be a mess if you aren't used to it, but it is just a matter of finding where all the right bits are and telling "CodeBlocks".

    Soma

  14. #14
    Registered User
    Join Date
    Mar 2013
    Posts
    35
    If you don't need 64bit then this is one of the best MinGW distros I've used.

    MinGW Distro - nuwen.net

    James
    stahta01 likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Standards and TC1/TC2
    By robwhit in forum C Programming
    Replies: 2
    Last Post: 07-28-2007, 12:04 PM
  2. Standards
    By Brain Cell in forum C Programming
    Replies: 23
    Last Post: 07-01-2004, 06:22 AM
  3. C ++ Standards
    By explosive in forum C++ Programming
    Replies: 8
    Last Post: 05-05-2004, 10:33 AM
  4. new C++ standards
    By Nectron in forum C++ Programming
    Replies: 6
    Last Post: 06-12-2003, 02:38 PM
  5. Program Portability (code portability)
    By Perica in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2002, 09:03 AM

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