Building on linux error with clang 3.4.1

Issue #30 resolved
Rui Coelho
created an issue

I'm trying to use this on linux but a get a lot of errors saying: error: macro "DIAG" requires 10 arguments, but only 9 given, for all DIAG macros in

n file included from /home/rui/dev/clreflect/src/clReflectScan/../../extern/llvm/tools/clang/include/clang/Basic/DiagnosticIDs.h:54:0,
                 from /home/rui/dev/clreflect/src/clReflectScan/../../extern/llvm/tools/clang/include/clang/Basic/Diagnostic.h:17,
                 from /home/rui/dev/clreflect/src/clReflectScan/../../extern/llvm/tools/clang/include/clang/AST/Type.h:17,
                 from /home/rui/dev/clreflect/src/clReflectScan/../../extern/llvm/tools/clang/include/clang/AST/Attr.h:19,
                 from /home/rui/dev/clreflect/src/clReflectScan/../../extern/llvm/tools/clang/include/clang/AST/DeclBase.h:17,
                 from /home/rui/dev/clreflect/src/clReflectScan/../../extern/llvm/tools/clang/include/clang/AST/Decl.h:18,
                 from /home/rui/dev/clreflect/src/clReflectScan/ASTConsumer.cpp:23:
/usr/include/clang/Basic/ error: macro "DIAG" requires 10 arguments, but only 9 given
 DIAG(err_attribute_not_type_attr, CLASS_ERROR, diag::MAP_ERROR, "%0 attribute cannot be applied to types", 0, SFINAE_SubstitutionFailure, false, false, 4)
/usr/include/clang/Basic/ error: macro "DIAG" requires 10 arguments, but only 9 given
 DIAG(err_cannot_open_file, CLASS_ERROR, diag::MAP_FATAL, "cannot open file '%0': %1", 0, SFINAE_SubstitutionFailure, false, false, 0)

Any idea how to fix this?

Sorry if I shouldn't ask this here, but I didn't know where else to go.


Comments (7)

  1. Don Williamson repo owner

    I'm going to base this reply on the assumption that the compiler you are using to build clReflect is clang 3.4.1 and that clReflect is still including the clang 3.1 that it ships with.

    If this is the case then the build process is getting confused.

    The error emits from here:


    This is the clang 3.1 source. Looking at the code, the line is:

    #include "clang/Basic/"

    and this ends up including:


    which is the wrong file. My guess is that this file is coming from the clang 3.4.1 installation that you are using to build clReflect and it needs to use the one here:


    Does that file exist for you? Have you built clang 3.1 first?

  2. Rui Coelho reporter

    Yea, I was building clReflect with the clang 3.4.1 that is installed on my system, and wasn't building clang 3.1 that comes with clReflect first.

    Edit: I've tried to build it (/home/rui/dev/clreflect/extern/ now, but I get another error:

    -- Found PythonInterp: /usr/bin/python (found version "3.4.1") 
    -- Constructing LLVMBuild project information
    CMake Error at CMakeLists.txt:300 (message):
      Unexpected failure executing llvm-build: Traceback (most recent call last):
        File "/home/rui/dev/clreflect/extern/llvm/utils/llvm-build/llvm-build", line 3, in <module>
          import llvmbuild
        File "/home/rui/dev/clreflect/extern/llvm/utils/llvm-build/llvmbuild/", line 1, in <module>
          from main import main
      ImportError: No module named 'main'
    -- Configuring incomplete, errors occurred!
    See also "/home/rui/dev/clreflect/extern/llvm-build-gnu/CMakeFiles/CMakeOutput.log".
    See also "/home/rui/dev/clreflect/extern/llvm-build-gnu/CMakeFiles/CMakeError.log".

    Edit 2: Not sure if it helps, but CMakeError.log says

    /usr/bin/cmake -E cmake_progress_report /home/rui/dev/clreflect/extern/llvm-build-gnu/CMakeFiles/CMakeTmp/CMakeFiles 1
    Building CXX object CMakeFiles/cmTryCompileExec3635390713.dir/src.cxx.o
    /usr/bin/c++    -fPIC -fvisibility-inlines-hidden -DSUPPORTS_COVERED_SWITCH_DEFAULT_FLAG   -Werror -Wcovered-switch-default -o CMakeFiles/cmTryCompileExec3635390713.dir/src.cxx.o -c /home/rui/dev/clreflect/extern/llvm-build-gnu/CMakeFiles/CMakeTmp/src.cxx
    c++: error: unrecognized command line option '-Wcovered-switch-default'
    CMakeFiles/cmTryCompileExec3635390713.dir/build.make:60: recipe for target 'CMakeFiles/cmTryCompileExec3635390713.dir/src.cxx.o' failed
    make[1]: Leaving directory '/home/rui/dev/clreflect/extern/llvm-build-gnu/CMakeFiles/CMakeTmp'
    make[1]: *** [CMakeFiles/cmTryCompileExec3635390713.dir/src.cxx.o] Error 1
    Makefile:117: recipe for target 'cmTryCompileExec3635390713/fast' failed
    make: *** [cmTryCompileExec3635390713/fast] Error 2
    Source file was:
    int main() { return 0;}
  3. Rui Coelho reporter

    Only managed to look into this again today, but yea. Seems I had Python 2 and 3 installed, but the default one is Python 3. So I just changed the cmake command in to:

    cmake -DPYTHON_EXECUTABLE=/usr/bin/python2 -G "Unix Makefiles" ../llvm && make

    And that did it :)

  4. Rui Coelho reporter

    I have managed to compile the code with clang 3.1, but I had to add const to the QualType argument of the ClangASTType constructor.

    ClangASTType(const clang::QualType& qt)

    But I don't know if it was because of the that or not, when I try to run clReflectTest it crashes: Screenshot - 07042014 - 03:00:33 PM.png

    Any idea what it could be?

    This is the log file clReflectTest.cppbin.log:

  5. Don Williamson repo owner

    I'll double-check that compile error but the crash you;re getting is in the test programs trying to call functions.

    On Linux/OSX function call address reflection doesn't work due to problems with the Linux ABI functions.

    David Meiners has been working on fixes to this in his own fork here:

    Everything else should work for you but if you need function address reflection, try grabbing some of his changes until he manages to put together a pull request for clReflect.

  6. Log in to comment