U.Mutlu via llvm-dev
2018-Jun-19 17:22 UTC
[llvm-dev] Naming clash: -DCLS=n and CLS in code
While building llvm & clang & libs by giving some optimization options to the building compiler, the following error happened: I think it is related to the passed -DCLS=64, because in file clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:6411 an enum member has the same name (CLS), so it does a macro-substitution with the passed value of CLS, ie. with 64, but which of course then breakes the syntax... I think such "reserved" names like CLS that can be passed to the compiler(s), should be avoided as identifiers for naming variables, constants, enum members, macros etc. [2845/3381] Building CXX object tools/clang/lib/Tooling/CMakeFiles/clangTooling.dir/Execution.cpp.o FAILED: /usr/local/gcc-latest/bin/g++-latest -DEXPENSIVE_CHECKS -D_DEBUG -D_GLIBCXX_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/lib/Frontend/Rewrite -I/sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite -I/sw/src/clang_llvm_dev/clang/include -Itools/clang/include -Iinclude -I/sw/src/clang_llvm_dev/llvm_trunk/include -fopt-info -pipe -Wall -Wextra -Ofast -DCLS=64 -fPIC -floop-nest-optimize --param simultaneous-prefetches=16 -fprefetch-loop-arrays -msse4.2 -mrecip=all -funroll-loops -fdelete-null-pointer-checks --param prefetch-latency=32 -ffast-math -ftree-vectorize -funsafe-math-optimizations -Wno-error=unused-parameter -Wno-error=type-limits -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++1y -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -pedantic -Wno-long-long -O3 -UNDEBUG -MD -MT tools/clang/lib/Frontend/Rewrite/CMakeFiles/clangRewriteFrontend.dir/RewriteModernObjC.cpp.o -MF tools/clang/lib/Frontend/Rewrite/CMakeFiles/clangRewriteFrontend.dir/RewriteModernObjC.cpp.o.d -o tools/clang/lib/Frontend/Rewrite/CMakeFiles/clangRewriteFrontend.dir/RewriteModernObjC.cpp.o -c /sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp <command-line>: error: expected identifier before numeric constant /sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:6411:3: note: in expansion of macro 'CLS' CLS = 0x0, ^~~ <command-line>: error: expected '}' before numeric constant /sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:6411:3: note: in expansion of macro 'CLS' CLS = 0x0, ^~~ /sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:6410:20: note: to match this '{' enum MetaDataDlags { ^ <command-line>: error: expected unqualified-id before numeric constant /sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:6411:3: note: in expansion of macro 'CLS' CLS = 0x0, ^~~ /sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:6421:1: error: expected declaration before '}' token }; ^ In file included from /sw/src/clang_llvm_dev/llvm_trunk/include/llvm/ADT/STLExtras.h:21, from /sw/src/clang_llvm_dev/llvm_trunk/include/llvm/ADT/StringRef.h:13, from /sw/src/clang_llvm_dev/llvm_trunk/include/llvm/ADT/StringMap.h:17, from /sw/src/clang_llvm_dev/llvm_trunk/include/llvm/Support/Host.h:17, from /sw/src/clang_llvm_dev/llvm_trunk/include/llvm/ADT/Hashing.h:49, from /sw/src/clang_llvm_dev/llvm_trunk/include/llvm/ADT/ArrayRef.h:13, from /sw/src/clang_llvm_dev/llvm_trunk/include/llvm/ADT/APFloat.h:21, from /sw/src/clang_llvm_dev/clang/include/clang/AST/APValue.h:18, from /sw/src/clang_llvm_dev/clang/include/clang/AST/Decl.h:17, from /sw/src/clang_llvm_dev/clang/include/clang/AST/ASTTypeTraits.h:20, from /sw/src/clang_llvm_dev/clang/include/clang/AST/ASTContext.h:18, from /sw/src/clang_llvm_dev/clang/include/clang/AST/AST.h:18, from /sw/src/clang_llvm_dev/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:15: ...
Tim Northover via llvm-dev
2018-Jun-19 17:55 UTC
[llvm-dev] Naming clash: -DCLS=n and CLS in code
On Tue, 19 Jun 2018 at 18:22, U.Mutlu via llvm-dev <llvm-dev at lists.llvm.org> wrote:> I think such "reserved" names like CLS that can be passed to the compiler(s), > should be avoided as identifiers for naming variables, constants, enum > members, macros etc.Why are you passing that argument in the first place? The compiler completely ignores it. I sort of assume some library makes use of it, but if so that library is certainly not required while compiling Clang and is actually obscure enough that it's not even obvious from Googling. So it's a bit of a stretch to claim the token is reserved. Cheers. Tim.
U.Mutlu via llvm-dev
2018-Jun-19 18:48 UTC
[llvm-dev] Naming clash: -DCLS=n and CLS in code
Tim Northover via llvm-dev wrote on 06/19/2018 07:55 PM:> On Tue, 19 Jun 2018 at 18:22, U.Mutlu via llvm-dev > <llvm-dev at lists.llvm.org> wrote: >> I think such "reserved" names like CLS that can be passed to the compiler(s), >> should be avoided as identifiers for naming variables, constants, enum >> members, macros etc. > > Why are you passing that argument in the first place? The compiler > completely ignores it.CLS stands for cacheline size. It is an important parameter for optimization of the generated code, at least with gcc/g++. -DCLS=n should have the same importance like for example -DNDEBUG.> I sort of assume some library makes use of it, but if so that library > is certainly not required while compiling Clang and is actually > obscure enough that it's not even obvious from Googling. So it's a bit > of a stretch to claim the token is reserved.Yes, it might not be required for the Average Joe user, but that's not me :-) Let me wish you a Good Morning!... :-)