Note:
Goal of this work is to use some of the c++11 features in non c++11 compiler
Following steps are done,
Generate llvm bit code,
clang++ -emit-llvm -c test.cc -o test.o
Convert llvm bitcode to c++ code,
llc-3.4 test.o -o test.cpp -march=cpp
Getting below error while compiling the llvm generated c++ code using GNU g++
arunprasadr@geekvm:~/works/myex/llvm$ g++ test.cpp test.cpp:3:23: fatal error: llvm/Pass.h: No such file or directory compilation terminated.
I even tried adding llvm-dev include path, but still fails,
arunprasadr@geekvm:~/works/myex/llvm$ g++ test.cpp -I/usr/include/llvm-3.4 -I /usr/include/llvm-c-3.4
In file included from /usr/include/llvm-3.4/llvm/Support/type_traits.h:20:0,
from /usr/include/llvm-3.4/llvm/ADT/StringRef.h:13,
from /usr/include/llvm-3.4/llvm/PassRegistry.h:20,
from /usr/include/llvm-3.4/llvm/PassSupport.h:26,
from /usr/include/llvm-3.4/llvm/Pass.h:366,
from test.cpp:3:
/usr/include/llvm-3.4/llvm/Support/DataTypes.h:48:3: error: #error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
/usr/include/llvm-3.4/llvm/Support/DataTypes.h:52:3: error: #error "Must #define __STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h"
In file included from /usr/include/llvm-3.4/llvm/ADT/SmallVector.h:19:0,
from /usr/include/llvm-3.4/llvm/PassAnalysisSupport.h:22,
from /usr/include/llvm-3.4/llvm/Pass.h:367,
from test.cpp:3:
/usr/include/llvm-3.4/llvm/Support/MathExtras.h: In function ‘bool llvm::isInt(int64_t)’:
/usr/include/llvm-3.4/llvm/Support/MathExtras.h:264:33: error: there are no arguments to ‘INT64_C’ that depend on a template parameter, so a declaration of ‘INT64_C’ must be available [-fpermissive]
/usr/include/llvm-3.4/llvm/Support/MathExtras.h:264:33: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/usr/include/llvm-3.4/llvm/Support/MathExtras.h:264:65: error: there are no arguments to ‘INT64_C’ that depend on a template parameter, so a declaration of ‘INT64_C’ must be available [-fpermissive]
/usr/include/llvm-3.4/llvm/Support/MathExtras.h: In function ‘bool llvm::isUInt(uint64_t)’:
/usr/include/llvm-3.4/llvm/Support/MathExtras.h:290:36: error: there are no arguments to ‘UINT64_C’ that depend on a template parameter, so a declaration of ‘UINT64_C’ must be available [-fpermissive]
/usr/include/llvm-3.4/llvm/Support/MathExtras.h: In function ‘bool llvm::isIntN(unsigned int, int64_t)’:
/usr/include/llvm-3.4/llvm/Support/MathExtras.h:322:33: error: ‘INT64_C’ was not declared in this scope