std::string in a .c file
c, c++, std
Solution
Yes, it will cause numerous compiler errors if it's compiled as C code. If it's being compiled as C++ instead, then it will compile fine. For example, GCC has the `-x` option to select the language to compile as, so you can compile a `.c` as C++ if you want with `-x c++`. Likewise, the Microsoft Visual C++ compiler has the options `/Tc` and `/Tp` to select a source language of C and C++ respectively.
I suggest you fix your build system so that it doesn't pass the `-x c++` or `/Tp` flag to files not ending with typical C++ source file extensions (`.cc`, `.cpp`, `.cxx`, `c++`, and `.C`, though the last three are quite rare).
Problem
I've seen `std::string` used in a `.c` file. std is a c++ namespace and namespaces were introduced in c++. Why is that so? Shouldn't it throw an error?