zoukankan      html  css  js  c++  java
  • asm与__asm__

    Occasionally a valid ANSI/ISO program may be incompatible with the extensions in GNU C. To deal with this situation, the compiler option -ansi disables 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 called asm:

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

    The variable name asm is valid under the ANSI/ISO standard, but this program will not compile in GNU C because asm is 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.c
    ansi.c: In function `main':
    ansi.c:6: parse error before `asm'
    ansi.c:7: parse error before `asm'
    

    In contrast, using the -ansi option disables the asm keyword 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 are asm, inline, typeof, unix and vax. More details can be found in the GCC Reference Manual "Using GCC" (see section Further reading).

  • 相关阅读:
    oracle 语句 笔记
    10:基于Tomcat部署Web工程
    8.为什么IntelliJ IDEA首次加载比较慢
    04 全局配置,java 编意默认版本,1.6.修改配置
    02 IDEA创创建第一个maven工程
    01 安装IDEA
    spring security权限架架mvn坐标
    RBAC基于角色的权限访问控制
    MyBatis 中的#和$的区别
    python数据相关性分析 (计算相关系数)
  • 原文地址:https://www.cnblogs.com/smwikipedia/p/1355102.html
Copyright © 2011-2022 走看看