Some of our (customer-) projects are compiled with GCC and the option ‘-fno-asm’. In this case, the compilation will fail with an error like:
[…]/Eigen/src/Core/products/GeneralBlockPanelKernel.h: (Ln: 642) error :'asm' was not declared in this scope
Whith a newer GCC-version like 4.8.3, the error-message will show additionaly:
test.cpp:19:2: note: in expansion of macro 'EIGEN_ASM_COMMENT'
EIGEN_ASM_COMMENT("EIGEN PRODUCT PACK LHS");
The GCC-documentation implies, that ‘-fno-asm’ may not affect the standard-keywords asm (and inline); but that’s no true (for the keyword asm).
Similar to the header-file "Eigen\src\Core\util\Memory.h", which does already use the alternative keywords, following patch would solve this (small) issue:
---- Begin of (unified diff) patch ----
--- Eigen/src/Core/arch/NEON/PacketMath.h (revision 222)
+++ Eigen/src/Core/arch/NEON/PacketMath.h (working copy)
@@ -50,7 +50,7 @@
-#define __pld(x) asm volatile ( " pld [%[addr]]\n" :: [addr] "r" (x) : "cc" );
+#define __pld(x) __asm__ __volatile__ ( " pld [%[addr]]\n" :: [addr] "r" (x) : "cc" );
template<> struct packet_traits<float> : default_packet_traits
--- Eigen/src/Core/util/Macros.h (revision 222)
+++ Eigen/src/Core/util/Macros.h (working copy)
@@ -247,7 +247,7 @@
#if (defined __GNUC__) && ( defined(__i386__) || defined(__x86_64__) )
- #define EIGEN_ASM_COMMENT(X) asm("#" X)
+ #define EIGEN_ASM_COMMENT(X) __asm__("#" X)
---- End of (unified diff) patch ----
Ie., to use the alternative GCC-keyword(s), which are not affected by this GCC-option.
Best regards from Salzburg,
Thanks for the clear report.
This looks like a bug in GCC (or the documentation) that should probably be reported to them.
Having said that, given that we use __asm__ in Memory.h it seems sensible to be consistent and use __asm__ instead of asm everywhere. I was a bit worried about other non-GCC compilers, but it looks ICC is happy with __asm__ , the code in Eigen implies that clang is too, while Visual Studio interestingly seems to ignore any asm blocks and wants __asm instead .
https://bitbucket.org/eigen/eigen/commits/f70fc7de (dev branch)
https://bitbucket.org/eigen/eigen/commits/604d801e (3.2 branch)