Greg
Greg

Reputation: 1500

Determining the source of an included symbol in C++

I am currently working on a project which forbids the inclusion of C++'s standard library. One of the compiled files we are using lists the following symbol: _Xran__Q2_3std12_String_baseCFv

I believe this relates to standard library strings. Am I incorrect in thinking so? If not, is anyone aware of an effective way of tracing the point at which this symbol was included? A cursory search of the code base doesn't show anything obvious.

Upvotes: 7

Views: 1086

Answers (2)

user1071136
user1071136

Reputation: 15725

This doesn't seem to be VC mangling, which always start with a question mark.

It does, however, fit the G++ mangling scheme, as is suggested by running

$ c++filt  --format=gnu "_Xran__Q2_3std12_String_baseCFv"
std::_String_base::_Xran( const(void))

What's weird is that _Xran seems to be part of VC's implementation for std::string.

Anyway, the header you're looking for is probably #include <string>.

EDIT: As a result of c++filt's output - are you sure it is compiled in VC++ ?

Upvotes: 2

Baltram
Baltram

Reputation: 681

In case string.h is indeed included at some place, you can find out where:

Place in the next line after every #include directive the following code:

using namespace std;class string;struct{void hxtestfunc(void){typedef string hxtesttype;}};

When compiling, this will generate an "ambiguous symbol" error only if string.h (or any file that includes string.h directly or indirectly) was included somewhere before.

So the first reported "ambiguous symbol" error will lead you to the line right after the critical inclusion.

In Visual C++ you can use search&replace with regular expression:

Replace

"{#include.*}"

with

"\0\nusing namespace std;class string;struct{void htestfunc(void){typedef string htesttype;}};"

in the whole project.

Upvotes: 0

Related Questions