我在 x86_64 中编写此代码并编译并运行良好,
__asm__("nop"
: "=eax"(foo)
: //"eax"(foo),"ebx"(bar)
: "eax"
);
但是当我尝试在其他机器(x86_32)上编译时 gcc 触发错误:S
inline1.c:6: error: impossible constraint in _asm_
我无法修复它..:S
GCC 版本::
不编译:
tur@aso:~$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5.1' -- with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable- languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch -- enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
线程模型:posix gcc 4.4.3版(Ubuntu 4.4.3-4ubuntu5.1)
编译
git@srvcode:/home/git/code/asm$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1- 9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
线程模型:posix gcc 版本 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
谢谢大家!!
阿图尔。