What is the difference between 'asm', '__asm' and '__asm__'?

前端 未结 4 1867
梦如初夏
梦如初夏 2020-11-22 04:33

As far as I can tell, the only difference between __asm { ... }; and __asm__(\"...\"); is that the first uses mov eax, var and the sec

4条回答
  •  庸人自扰
    2020-11-22 05:14

    asm vs __asm__ in GCC

    asm does not work with -std=c99, you have two alternatives:

    • use __asm__
    • use -std=gnu99

    More details: error: ‘asm’ undeclared (first use in this function)

    __asm vs __asm__ in GCC

    I could not find where __asm is documented (notably not mentioned at https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Alternate-Keywords.html#Alternate-Keywords ), but from the GCC 8.1 source they are exactly the same:

      { "__asm",        RID_ASM,    0 },
      { "__asm__",      RID_ASM,    0 },
    

    so I would just use __asm__ which is documented.

提交回复
热议问题