In GCC and Clang, we can pass an integer variable into an attribute.
constexpr auto SIZE = 16;
int a [[gnu::vector_size(SIZE)]];
This is particularly useful when we write templates.
template<size_t N>
struct Vec {
int inner [[gnu::vector_size(N)]];
};
However, if the attribute requires a string, I cannot find a way to use a variable like that. Neither of these two approaches works.
constexpr const char* TARGET = "default";
[[gnu::target(TARGET)]] void foo() {}
constexpr const char TARGET[] = "default";
[[gnu::target(TARGET)]] void foo() {}
It there a way to achieve this?