This should work. At least, it is pure C++98
const int CLEAN = 0;
const int TARGET = 1;
const int LABELS_N = 2;
int LABELS_A[LABELS_N] = { CLEAN, TARGET};
const std::vector<int> LABELS(LABELS_A, LABELS_A+LABELS_N);
I'd also recommend you to enclose the additional items in a namespace:
namespace detail {
const int LABELS_N = 2;
int LABELS_A[LABELS_N] = { CLEAN, TARGET};
}
const std::vector<int> LABELS(detail::LABELS_A, detail::LABELS_A+detail::LABELS_N);
Another option is using an initializer class, especially if you have many global constants like this:
namespace detail {
struct Initializer
{
Initializer()
{
LABELS.push_back(CLEAN);
LABELS.push_back(TARGET);
}
std::vector<int> LABELS;
};
const Initializer initializer;
}
const std::vector<int>& LABELS = detail::initializer.LABELS;
And yes, you are likely to have more problems if you don't upgrade your compiler.