ASM and _ ASM __

Source: Internet
Author: User

Occasionally a valid ANSI/ISO program may be incompatible with the extensions in gnu c. To deal with this situation, the compiler option-ansiDisables those GNU extensions which are in conflict with the ANSI/ISO standard. On systems using the gnu c library (glibc) It also disables extensions to the C standard library. This allows programs written for ANSI/iso c to be compiled without any unwanted effects from GNU extensions.

For example, here is a valid ANSI/iso c program which uses a variable calledasm:

#include <stdio.h>intmain (void){  const char asm[] = "6502";  printf ("the string asm is '%s'\n", asm);  return 0;}

The variable nameasmIs valid under the ANSI/ISO standard, but this program will not compile in gnu c becauseasmIs a gnu c keyword extension (it allows native assembly instructions to be used in C functions). Consequently, it cannot be used as a variable name without giving a compilation error:

$ gcc -Wall ansi.cansi.c: In function `main':ansi.c:6: parse error before `asm'ansi.c:7: parse error before `asm'

In contrast, using-ansiOption disablesasmKeyword extension, and allows the program above to be compiled correctly:

$ gcc -Wall -ansi ansi.c$ ./a.out the string asm is '6502'

For reference, the non-standard keywords and macros defined by the gnu c extensions areasm,inline,typeof,unixAndvax. More details can be found in the GCC Reference Manual"Using gcc"(See section further reading ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.