Is gcc compliant with the C++ standards


 
Thread Tools Search this Thread
Top Forums Programming Is gcc compliant with the C++ standards
# 1  
Old 07-29-2009
Is gcc compliant with the C++ standards

Hello Friends,

I am a newbie and have started using different compilers and tools to make myself familiar with their workings. I wanted to know that how compliant is gcc with the C++ standards. It is pretty obvious that no compiler is close to being completely compliant, but if there are some things which are not according to the ANSI/ISO standard; what are they in gcc?

I will be very grateful if someone who is an expert user of gcc can answer this doubt of mine?

Regards.
# 2  
Old 07-30-2009
http://gcc.gnu.org/onlinedocs/gcc-4.4.1/gcc.pdf
There is a section on ANSI support. 4.4.1 does provide full ANSI support, except in specialty environments like embedded Linux or ARM, or in really old releases of gcc.

For C++ issues mostly boil down to extensions and implementation defined behaviors (semantics). You have read a lot, there is no way to shortcut that.
# 3  
Old 07-30-2009
Quote:
Originally Posted by hthapar
Hello Friends,

I am a newbie and have started using different compilers and tools to make myself familiar with their workings. I wanted to know that how compliant is gcc with the C++ standards. It is pretty obvious that no compiler is close to being completely compliant, but if there are some things which are not according to the ANSI/ISO standard; what are they in gcc?

I will be very grateful if someone who is an expert user of gcc can answer this doubt of mine?

Regards.
gcc can be told comply with standards, lots of them. Pick your favorite:
Code:
$ man gcc

GCC(1)                                GNU                               GCC(1)



NAME
       gcc - GNU project C and C++ compiler

SYNOPSIS
       gcc [-c|-S|-E] [-std=standard]
           [-g] [-pg] [-Olevel]
           [-Wwarn...] [-pedantic]
           [-Idir...] [-Ldir...]
           [-Dmacro[=defn]...] [-Umacro]
           [-foption...] [-mmachine-option...]
           [-o outfile] infile...

       Only the most useful options are listed here; see below for the remain-
       der.  g++ accepts mostly the same options as gcc.

...

       -std=
           Determine the language standard.  This option is currently only
           supported when compiling C or C++.  A value for this option must be
           provided; possible values are

           c89
           iso9899:1990
               ISO C90 (same as -ansi).

           iso9899:199409
               ISO C90 as modified in amendment 1.

           c99
           c9x
           iso9899:1999
           iso9899:199x
               ISO C99.  Note that this standard is not yet fully supported;
               see <http://gcc.gnu.org/gcc-4.1/c99status.html> for more infor-
               mation.  The names c9x and iso9899:199x are deprecated.

           gnu89
               Default, ISO C90 plus GNU extensions (including some C99 fea-
               tures).

           gnu99
           gnu9x
               ISO C99 plus GNU extensions.  When ISO C99 is fully implemented
               in GCC, this will become the default.  The name gnu9x is depre-
               cated.

           c++98
               The 1998 ISO C++ standard plus amendments.

           gnu++98
               The same as -std=c++98 plus GNU extensions.  This is the
               default for C++ code.

           Even when this option is not specified, you can still use some of
           the features of newer standards in so far as they do not conflict
           with previous C standards.  For example, you may use "__restrict__"
           even when -std=c99 is not specified.

           The -std options specifying some version of ISO C have the same
           effects as -ansi, except that features that were not in ISO C90 but
           are in the specified version (for example, // comments and the
           "inline" keyword in ISO C99) are not disabled.

gcc also has lots of language extensions, but you don't need to use them.
# 4  
Old 07-30-2009
Quote:
It is pretty obvious that no compiler is close to being completely compliant
I am curious how you came to that conclusion.
# 5  
Old 07-30-2009
I have been using VS2005 for some time and also did a lot of reading on other compilers.
Well I observed that, each platform is providing extensions and libraries based only for their system/platform and at the same time even if you are able to port these platform-specific libraries to other compilers, still the compliance issue is lost to some extent.
Maybe I was wrong in generalizing it, but it was just an opinion.
# 6  
Old 07-30-2009
Moving an application from Microsoft C++ to another C++ environment is nearly always challanging. Build failures usually comes down to (1) the silent non-standard compiler extensions that Microsoft supports by default (for example lvalue casts, zero length structure members) and (2) the fact that common C++ libraries have yet to be fully standardized. It is rarely the core C++ compiler itself.
# 7  
Old 07-30-2009
Very true
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. OS X (Apple)

Generate a random number in a fully POSIX compliant shell, 'dash'...

Hi all... Apologies for any typos, etc... This took a while but it didn't beat me... Although there are many methods of generating random numbers in a POSIX shell this uses integer maths and a simple C source to create an executable to get epoch to microseconds accuracy if it is needed. I take... (8 Replies)
Discussion started by: wisecracker
8 Replies

2. Shell Programming and Scripting

Q: Is SQRT(n) possible in a POSIX compliant shell? A: Yes within limits.

Hi all... This is just a fun project to see if it is possible to get a square root of a positive integer from 1 to 9200000 to 6 decimal places on a 64 bit architecture machine. It is coded around dash and the results show the values from 0 to 10000. Complex numbers can easily be catered for by... (3 Replies)
Discussion started by: wisecracker
3 Replies

3. Shell Programming and Scripting

Logical expression in POSIX compliant Korn Shell

Hi, i want to check if a variable var1 is not a or b or c pseudo code: If NOT (var1 = a or var1 = b or var1 = c) then ... fi I want to use POSIX complaint Korn shell, and for string comparison For the following code, logical.sh #!/usr/bin/ksh var="j" echo "Var : $var" if ! { || ||... (12 Replies)
Discussion started by: ysrini
12 Replies

4. UNIX for Dummies Questions & Answers

Making times mysql compliant

I have the following file: Loc1,20080102,230100,0.5617,0.5617 Loc1,20080102,230400,0.5616,0.5616 Loc1,20080102,230700,0.5615,0.5615 Then I use the following code to turn the third column into something which to mysql has the time datatype: sed -i '' -e "s#,\(..\)\(..\)\(..\),#,\1:\2:\3,#"... (2 Replies)
Discussion started by: figaro
2 Replies

5. Solaris

Installing gcc - recieve error message gcc : cannot execute

AIM- Install Oracle 11g on Solaris using VMWare Steps 1.Logged on as root 2.Created subfolders à /usr/local/bin & /usr/local/bin/gcc 3.Downloaded gcc & libiconv & unzipped them on my harddrive & burnt them on CD 4.Copied files from CD to /usr/local/bin/gcc 5.Terminal (root) à pkgadd -d... (8 Replies)
Discussion started by: Ackers
8 Replies

6. Solaris

Security Standards...

Hi All, Thanks in advance for reading and any posts. I was wondering if anyone has come across or can recomend or has any security standards that we could implement. We are running production Oracle systems on Solaris 8 boxes (which are global). We are after security considerations... (4 Replies)
Discussion started by: B14speedfreak
4 Replies

7. Programming

UNIX version standards

I'm new to UNIX programming. I'm used to starting my program's versions at 1.0, but I look at all the UNIX programs out there and see things like 0.000.1 or 3.3.000 and I'm wondering what these things really mean. Do people just type anything they feel in there? Are things in pre-release... (6 Replies)
Discussion started by: hirni
6 Replies

8. UNIX for Dummies Questions & Answers

Standards

I have been asked to put together some coding standards for the project I am assigned to. I have found documented standards for C/C++, Java but was wondering if there is a good place for UNIX scripting (Korn/Bourne) standards? Does anyone know of a good place to find information on scripting... (3 Replies)
Discussion started by: google
3 Replies
Login or Register to Ask a Question