기본 콘텐츠로 건너뛰기

C 표준, GCC 그리고 컴파일 옵션

GCC supports three versions of the C standard, although support for the most recent version is not yet complete.

The original ANSI C standard (X3.159-1989) was ratified in 1989 and published in 1990. This standard was ratified as an ISO standard (ISO/IEC 9899:1990) later in 1990. There were no technical differences between these publications, although the sections of the ANSI standard were renumbered and became clauses in the ISO standard. This standard, in both its forms, is commonly known as C89, or occasionally as C90, from the dates of ratification. The ANSI standard, but not the ISO standard, also came with a Rationale document. To select this standard in GCC, use one of the options -ansi-std=c90 or -std=iso9899:1990; to obtain all the diagnostics required by the standard, you should also specify -pedantic (or -pedantic-errors if you want them to be errors rather than warnings). See Options Controlling C Dialect.
Errors in the 1990 ISO C standard were corrected in two Technical Corrigenda published in 1994 and 1996. GCC does not support the uncorrected version.

An amendment to the 1990 standard was published in 1995. This amendment added digraphs and __STDC_VERSION__ to the language, but otherwise concerned the library. This amendment is commonly known as AMD1; the amended standard is sometimes known as C94 or C95. To select this standard in GCC, use the option -std=iso9899:199409 (with, as for other standard versions, -pedantic to receive all required diagnostics).

A new edition of the ISO C standard was published in 1999 as ISO/IEC 9899:1999, and is commonly known as C99. GCC has incomplete support for this standard version; see http://gcc.gnu.org/c99status.html for details. To select this standard, use -std=c99 or -std=iso9899:1999. (While in development, drafts of this standard version were referred to as C9X.)
Errors in the 1999 ISO C standard were corrected in three Technical Corrigenda published in 2001, 2004 and 2007. GCC does not support the uncorrected version.

A fourth version of the C standard, known as C11, was published in 2011 as ISO/IEC 9899:2011.  GCC has limited incomplete support for parts of this standard, enabled with -std=c11 or -std=iso9899:2011. (While in development, drafts of this standard version were referred to as C1X.)

By default, GCC provides some extensions to the C language that on rare occasions conflict with the C standard. See Extensions to the C Language Family. Use of the -std options listed above will disable these extensions where they conflict with the C standard version selected. You may also select an extended version of the C language explicitly with -std=gnu90 (for C90 with GNU extensions), -std=gnu99 (for C99 with GNU extensions) or -std=gnu11 (for C11 with GNU extensions). The default, if no C language dialect options are given, is -std=gnu90; this will change to -std=gnu99 or -std=gnu11 in some future release when the C99 or C11 support is complete. Some features that are part of the C99 standard are accepted as extensions in C90 mode, and some features that are part of the C11 standard are accepted as extensions in C90 and C99 modes.



[출처] http://gcc.gnu.org/onlinedocs/gcc/Standards.html

이 블로그의 인기 게시물

특수문자와 서식화 문자

ASCII 특수 문자\a경고음 발생\b백스페이스\f폼 피드\n개행\r캐리지 리턴\t수평 탭\v수직 탭\\역 슬래시 (\)\'작은 따옴표 (')\"큰 따옴표 (")
서식 문자%d, %i10진 정수%x, %o16진수, 8진수 정수(양수만)%f, %lf10진수 실수%c하나의 문자%s문자열%u10진 정수 (양수만)%e지수표기법에 의한 실수%E지수표기법에 의한 실수%g소수점 이하 자리수에 따라 %f, %e중 하나를 선택%G소수점 이하 자리수에 따라 %f, %e 중 하나를 선택%%%기호 출력
%03d필드 폭을 3칸 확보하고 남는 자리는 0으로 채움%-3d필드 폭을 3칸 확보하고 왼쪽 정렬%+3d필드 폭을 3칸 확보하고 오른쪽 정렬. 부호 출력.

조건문

if 1 if(조건) 명령문;

if - else 1 if(조건) 2 { 3 명령문1; 4 } 5 else 6 { 7 명령문2; 8 }

if - else if 1 if(조건) 2 { 3 명령문1; 4 } 5 else if 6 { 7 명령문2; 8 } 9 else10 {11 명령문3;12 }

switch - case case절에는 break문을 사용해서 다른 절이 실행되지 않도록 해야 한다. case절에서 제시된 조건 중에 하나도 맞지 않는 경우에 default절이 실행된다. 1 switch(조건) 2 { 3 case 값1: 4 명령문1; 5 break; 6 7 case 값2: 8 명령문2; 9 break;10 11 default:12 명령문3;13 }