tl;dr: Can I somehow make this code work in C++14 (GCC 6.3)?
int main(){
#include<vector>
std::vector<int> v{1,2,3};
return 0;
}
But code below works just fine!
#include <iostream>
using namespace std;
int main() {
#include<cstdio>
using namespace __gnu_cxx;
printf("Hello world\n.");
return 0;
}
Using C++14 (gcc-6.3) code doesn't compile with error message being
error: 'namespace' definition is not allowed here
namespace std
^~~~~~~~~
Why I want to do this?
I don't have access outside of the function where I am allowed to code. I can't #include in global area.
UPD: Changing to cstdlib also works problem is not exclusion by header guard (according to me) but namespace problem. Because C++ header files have namespace std, while c header files doesn't. I wanted to ask whether there is some tweak for namespace issue?