Issues running a simple out of source LLVM pass

淺唱寂寞╮ 提交于 2019-12-06 00:27:03
Hadi Brais

The compiler is complaining about constexpr which is a C++11 feature. Make sure that C++11 is enabled by passing the -std=c++11 switch to gcc (or Clang, same switch for both compilers). This will fix all the errors you're seeing. Since you're using a makefile, you should add this switch to the CXXFLAGS variable as shown here.

UPDATE: Disregard this answer. The answer about C++11 is correct.

It can't find a definition for constexpr. This is either a typedef as in typedef something constexpr, but much more likely a macro as in #define constexpr const

It should be defined in a .h file somewhere (or within the makefile as -Dconstexpr=const).

NOTE: On the page you cited, they suggested adding -D's to the makefile. Also, see the second answer that used llvm-config --cppflags. Just type it in and see what it outputs.

But, it you have to troubleshoot further ...

First, find the file that has the definition via something like:

egrep -r '#define.*constexpr' .
You may get a few extras. Sift through them and find the file that has the definition. Then, look for an #ifdef BLAH wrapper around it. BLAH is not being defined properly.

If BLAH turns out to be one of the __STDC_* you mentioned, you may need to define it indirectly as sometimes certain .h files will undef these and redef them, based on a more "global" symbol (e.g. STDC_* or _STDC_SOURCE)

For example, with GNU, to get the sub features, you don't define them directly, you use _GNU_SOURCE which turns on a whole bunch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!