My goal is to separate all vectorclass-library typenames to a separate namespace, so that vcl::Vec4i will compile, but Vec4i won't. I tried to use example from manual, however it's not working.
Failed attempt following the manual:
#include <iostream>
#include "vcl/vectorclass.h"
#define VCL_NAMESPACE vcl
using namespace vcl; //error
int main() {
vcl::Vec4i vec; //error
Vec4i vec; //still compiles
return 0;
}
Failure message:
root@vlad:/avx_vcl clang++ -std=c++17 -mavx -o test main.cpp
main.cpp:4:17: error: expected namespace name
using namespace vcl;
^
main.cpp:6:2: error: use of undeclared identifier 'vcl'
vcl::Vec4i vec;
^
2 errors generated.
Desired result:
#define VCL_NAMESPACE vcl
int main() {
vcl::Vec4i vec; //compiles
Vec4i vec; //won't compile
return 0;
}
What should I change?
using namespace vcl;seems to be contrary to the stated goal. By importing all the names, both code versions will still compile..cppfile isn't too bad. The point is probably to not pollute the global namespace with the vcl stuff, so as long as OP doesn't dousing namespace vcl;inside the global namespace in header files, I think it's fine.