I
I
idclev312016-06-30 21:30:28
C++ / C#
idclev31, 2016-06-30 21:30:28

Why doesn't the code compile when connecting vector?

When including the vector library, the code does not compile with an error in several files, for example, alloc_traits.h on the line namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
The error itself looks like this: error:namespace definition is not allowed here
What could be the problem here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2016-06-30
@idclev31

Most likely, somewhere in the previous header - in what is in front of ours <vector> - something is not closed (namespace, function, etc.)
UPD2. It turned out to repeat the error with this code.

void x() {
#include <vector>
};

If instead of the x() function we take a class or namespace, the error will be different.
So 90% that you didn't balance the parentheses in the function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question