Description
Describe the bug
I'm attempting to build this compiler to try out the C++26 reflection however I can't seem to get any examples to compile.
The issue each time is that fatal error: 'experimental/meta' file not found
. I'm not sure what compile option I need to add so that it compiles.
I have searched for the meta header file with find | grep "meta"
in the folder where I built clang and it returns no results which makes me think that there may be an option in the build steps that I have not enabled that keeps experimental/meta from being added to the final build.
I have confirmed that experimental/meta is in the repository.
To Reproduce
Building clang
mkdir build
cd build
cmake -G "Visual Studio 17" -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Release ..\llvm
cmake --build .
Compile the code
clang.exe -freflection -std=c++26 -fexpansion-statements .\main.cpp -o main.exe
Result:
.\main.cpp:1:10: fatal error: 'experimental/meta' file not found
1 | #include <experimental/meta>
| ^~~~~~~~~~~~~~~~~~~
1 error generated.
Code that I'm trying to compile: main.cpp
#include <experimental/meta>
#include <iostream>
#include <string>
template <typename E>
constexpr std::string enum_to_string(E value) {
template for (constexpr auto e : std::meta::members_of(^E)) {
if (value == [:e:]) {
return std::string(std::meta::name_of(e));
}
}
return "<unnamed>";
}
enum Color { red, green, blue };
int main() {
std::cout << enum_to_string(Color::red) << std::endl;
}
Expected behavior
The code should build and when I run it, it should print red.
Environment (please complete the following information):
Windows 10
Visual Studio 17
I've tried almost all variants of these instructions. I've compiled the code with clang.exe -freflection -std=c++26 -fexpansion-statements -fparameter-reflection -fexpansion-statements -fconsteval-blocks -freflection-new-syntax -freflection-latest .\main.cpp -o main.exe
. I've removed the #include <experimental/meta>
and tried to compile it.