# simple scriptstdstring.cpp patch

This topic is 3210 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello all I have been working on the Rigs of Rods project using x86_64 on Kubuntu 9.04. I had to make a simple change to get Angelscript to compile. Sorry I don't have the exact error message but it complained that strstr (not found/defined/etc) below is the generated patch for the change
diff -U 3 -H -d -r -N -- sdk/add_on/scriptstdstring/scriptstdstring.cpp sdk-org/add_on/scriptstdstring/scriptstdstring.cpp
@@ -455,7 +455,7 @@

void RegisterStdString(asIScriptEngine * engine)
{
-	if (strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY"))
+	if (string((asGetLibraryOptions()).find("AS_MAX_PORTABILITY") != string::npos)
RegisterStdString_Generic(engine);
else
RegisterStdString_Native(engine);



##### Share on other sites
I find it hard to believe that strstr() isn't available, as it is a standard C function. Rather than changing the code to use std::string::find(), could you help me determine what would be the correct header file to include for the strstr() function?

##### Share on other sites
According to the C standard, strstr() is in string.h.

##### Share on other sites
Yes. Thanks.

I'd still prefer if Aperion could confirm that adding #include <string.h> fixes the problem he had though.

##### Share on other sites
Quote:
 Original post by WitchLordYes. Thanks.I'd still prefer if Aperion could confirm that adding #include fixes the problem he had though.

I tried it multiple ways #include <cstring> works and #include <string.h> Would cstring be the more appropriate way for c++?

##### Share on other sites
I really can't say. But if #include <string.h> works then that's what I'll do. This is what I have in the other add-ons anyway, I guess I just forgot to add it to this one.

##### Share on other sites
According to the C++ standard, if you include cstring, then it takes all the functions and puts them in the std namespace without putting them in the root namespace. If you include string.h then it puts the functions in both the root namespace and the std namespace. In practice, pretty much every compiler puts the functions in both if you include cstring, with the one exception I know of being Borland's C++ compilers, which only puts the functions in the std namespace. This basically means that string.h is the right choice if you don't want to prefix everything with std::.

##### Share on other sites
Quote:
 Original post by SiCraneAccording to the C++ standard, if you include cstring, then it takes all the functions and puts them in the std namespace without putting them in the root namespace. If you include string.h then it puts the functions in both the root namespace and the std namespace. In practice, pretty much every compiler puts the functions in both if you include cstring, with the one exception I know of being Borland's C++ compilers, which only puts the functions in the std namespace. This basically means that string.h is the right choice if you don't want to prefix everything with std::.

ok, thanks for the explanation