A Compiler With Support For C++11

0 views
Skip to first unread message

Nancy Benigar

unread,
Aug 4, 2024, 4:40:57 PM8/4/24
to riddswivunin
Youcan refer to following link to know which features are supported in which version of compiler. It has an exhaustive list of feature support in modern compilers. Seems like GCC follows the standard very closely and implements before any other compiler.

The compiler can accept several base standards, such as c89 or c++98, and GNU dialects of those standards, such as gnu89 or gnu++98. By specifying a base standard, the compiler will accept all programs following that standard and those using GNU extensions that do not contradict it. For example, -std=c89 turns off certain features of GCC that are incompatible with ISO C90, such as the "asm" and "typeof" keywords, but not other GNU extensions that do not have a meaning in ISO C90, such as omitting the middle term of a "?:" expression. On the other hand, by specifying a GNU dialect of a standard, all features the compiler support are enabled, even when those features change the meaning of the base standard and some strict-conforming programs may be rejected. The particular standard is used by -pedantic to identify which features are GNU extensions given that version of the standard. For example-std=gnu89 -pedantic would warn about C++ style // comments, while -std=gnu99 -pedantic would not.


While GCC 4.7 does have some C++11 capabilities, it is severely lacking most of the features needed. So while the configure script uses the correct option to enable C++11, the compiler can't actually handle the test-program because it uses features not available in the old GCC 4.7 version you have.


If you want to use Breakpad you need either an older version of Breakpad that supports your old compiler, or you need to update your compiler to a more recent release. The 5 series should have full support for C++11.


Now, if you are looking for a standard way to check if the compiler supports a whatsoever subset of C++11 features, I think there is no standard, portable way; you can check compilers documentation or std library header files to get more information.


If you do not want to use Boost.Config and need to test for compilers that support C++11 then checking the value of the constant __cplusplus will do. However, a compiler might support most of the popular features of the C++11 standard yet it does not support the entire specifications. If you want to enable support for specific Visual Studio compilers which are not yet 100% compliant to C++11 specifications then use the following code snippet which allows compiling in Visual Studio 2013:


In the traditional Linux/Unix world, autoconf is traditionally used to test for the presence of libraries and compiler features and bugs placing them into a config.h that you use in your files as needed.


When this question was asked in February 2011, support for C++11 was inconsistent. Compilers needed time to catch up to the standard, so in the meantime, they released with partial support. For example, a compiler might have implemented variadic templates, but not auto.


One pragmatic solution was to use the third-party Boost.Config library, which maintained a bunch of feature test macros. Boost.Config's maintainers kept track of which compilers supported which features, and updated the macros accordingly for each Boost.Config release.


The following table lists new language features that have been accepted into the C++20 working draft. The "Proposal" column provides a link to the ISO C++ committee proposal that describes the feature, while the "Available in GCC?" column indicates the first version of GCC that contains an implementation of this feature (if it has been implemented).


The following table lists new language features that have been accepted into the C++17 working draft. The "Proposal" column provides a link to the ISO C++ committee proposal that describes the feature, while the "Available in GCC?" column indicates the first version of GCC that contains an implementation of this feature (if it has been implemented).


Important: Because these Technical Specifications are still evolving toward future inclusion in a C++ standard, GCC's support is experimental. No attempt will be made to maintain backward compatibility with implementations of features that do not reflect the final standard.


The following table lists new language features that are part of the C++14 standard. The "Proposal" column provides a link to the ISO C++ committee proposal that describes the feature, while the "Available in GCC?" column indicates the first version of GCC that contains an implementation of this feature.


I am trying to port a project from C to C++. At least during the transition, I would like to be able to compile it in either mode so I can compare performance, memory usage, etc. so I am trying to make the code use a common subset of features that are supported in both languages. Currently the code uses designated initializers in a lot of places, which work great in C and won't compile in C++ mode (I get error "#2719: a designator for an anonymous union member can only appear within braces corresponding to that anonymous union"). I think that is most likely because the TI v20.2.0.LTS compiler I am using (which came with CCS10) supports only C++14, not C++20. I realize that C++20's support for designated initializers is limited compared with C++11, but I think I could deal with that pretty easily. Do I have any good options for making this code compile in both C and C++ modes?


Thanks, George, for the reply. At first I misunderstood what was significant about the change you showed and thought that the key was wrapping the structure members in unions (I used unions for each one since they needed to be stored in separate memory locations). When compiled as C, that gave me exactly the same binary image as without the "union" wrappers. It also compiled as C++ (I still couldn't link because of other errors).


I then ran into some bit fields, and figured that wrapping them in individual unions was going to prevent them from packing correctly. So I dug a little deeper and figured out that the key was avoiding anonymous structs or unions, rather than wrapping members in unions. So, as in your example, I added names to nested structures and unions (so they were no longer anonymous) and inserted that name in the references to them (x->union_member.u1). That seems to have solved my problem. I don't know if it is standard C++11 or not, but it works in CSS which is all that really matters in this application (I think it is probably valid C and C++20).


Building ROOT was my first experience with CMake and I did not set the flag -Dcxx17=ON. Having used inline variables, fold expressions and deduced return types, I get error messages and warnings. I notice the flag -std=c++17 is ignored, possibly because of root-config which comes after and sets c++11 support. Therefore I tried putting it at the end of the command, which results in compile errors in several ROOT headers, starting from:


I get the list of errors in ROOT headers I mentioned before, for example non-matching declarations, use of the incomplete type TString, use of non-template classes as templates and entities defined in namespace std which are not qualified and therefore are undeclared.


It is possible that your compiler may not support the C++11 standard. Make sure you are using a compatible compiler, such as Clang or GCC, which have full support for C++11. You can also try updating your compiler to the latest version.


If you have tried all the above steps and are still facing issues, you can try cleaning and rebuilding your project in CLion. Sometimes, old build artifacts can cause conflicts with the C++11 settings. You can also try restarting CLion or your computer to see if that resolves the issue.


(8): This is a backwards-incompatible change that is applied toall language versions that allow type deduction from auto(per the request of the C++ committee).In Clang 3.7, a warning is emitted for all cases that would change meaning.

(9): Under the MS ABI, function parameters are destroyed fromleft to right in the callee. As a result, function parameters in calls tooperator, operator->*,operator&&, operator, and operator,functions using expression syntax are no longer guaranteed to be destroyed inreverse construction order in that ABI.This is not fully supported during constant expression evaluation until Clang 12.

(10): While this feature was initially implemented in Clang 4,it was not enabled by default prior to clang 19, but could be enabled with-frelaxed-template-template-args.Starting from Clang 19, the flag is deprecated and will be removed in a futureversion.


Clang implements all of the ISO C++ 1998 standard (including the defects addressed in the ISO C++ 2003 standard) except for export (which was removed in C++11).Defect reportsClang generally aims to implement resolutions to Defect Reports (bug fixesagainst prior standards) retroactively, in all prior standard versions wherethe fix is meaningful. Significant Defect Report changes to language featuresafter the publication of the relevant standard are marked (DR) in the abovetable.


Clang also has a test suite for conformance to resolutions for issues on theC++ core issues list,most of which are considered Defect Reports.Implementation status for C++ core issues based onthat test suite is tracked on a separate page.


What do you mean "the document's not available to the public"? The compiler is Open Source. No only can you read the documentation, you can read the source code that implements the documentation. And you can modify that source code and make your own compiler to have it act however you like.


This is part of the 2003 standard since that's when I bought the book yet it is not working.

Can someone confirm that this is NOT part of the gcc g++.

This is called an explicit specialization of the template class. I'm trying to learn C++ again using Arduino gcc but come up short using it.


OK now we're getting somewhere because there are 6 more newer versions. It also explains why it does not work any more. So now, I hope, I can get the right version after pulling a lot of teeth.

Thanks, again for your hep.

pamam

3a8082e126
Reply all
Reply to author
Forward
0 new messages