Stlport Tips
1. stlport 静态链接与动态链接
如果程序要使用静态库的话必须定义宏:_STLP_USE_STATIC_LIB
如果程序要使用动态库的话必须定义宏: _STLP_USE_DYNAMIC_LIB (貌似这个是默认的)
2. Visual C++ says “LNK1104: cannot open file 'stlport_statix.lib'”
Problem solved. I had a project in the solution using /MD instead of /MT, that I had overlooked.
Long explanation: STLport can be built either for dynamic linking or static linking. It can also be built for static linking, but with a dynamically linked runtime library. The latter results in a library called "stlport_statix.lib", whereas the normal statically linked one is called "stlport_static.lib".
When you are building with STLport, _auto_link.h decides what version to link against, based on whether you are using /MD or /MT.
For details, see _auto_link.h lines 27-39 and _detect_dll_or_lib.h lines 32-65 (assuming STLport 5.2.1).
3. std::string 中 c_str() 和 data() 的区别
//z 2012-11-28 14:36:24 IS2120@BG57IV3.T905106419 .K[T35,L365,R14,V313]
c_str() return a pointer to the data with a NUL byte appended so you can use the return value as a "C string".
data() returns a pointer to the data without any modifications.
Use c_str() if the code you are using assumes a string is NUL terminated (such as any function written to handle C strings).
The c_str()
result becomes invalid if the std::string
is destroyed or if a non-const member function of the string is called. So, usually you will want to make a copy of it if you need to keep it around.
In the case of your example, it appears that the results of c_str()
are used safely, because the strings are not modified while in that scope. (However, we don't know whatuse_foo()
or
~Foo()
might be doing with those values; if they copy the strings elsewhere, then they should do a truecopy, and not just move the
char
pointers around.)
std::string::c_str
const char* c_str ( ) const;
A terminating null character is automatically appended.
The returned array points to an internal location with the required storage space for this sequence of characters plus its terminating null-character, but the values in this array should not be modified in the program and are only guaranteed to remain unchanged until the next call to a non-constant member function of the string object.
Parameters
noneReturn Value
Pointer to an internal array containing the c-string equivalent to the string content.std::string::data
const char* data() const;
Notice that no terminating null character is appended (see member c_str for such a functionality).
The returned array points to an internal location which should not be modified directly in the program. Its contents are guaranteed to remain unchanged only until the next call to a non-constant member function of the string object.
Parameters
noneReturn Value
Pointer to an internal array containing the same content as the string.@IS2120#CNBLOGS.T2169364049[T1,L65,R1,V259]:备忘
$ € ₤ ₭ ₪ ₩ ₮ ₦ ₱ ฿ ₡ ₫ ﷼ ¥ ﷼ ₫ ₡ ฿ ₱ ₦ ₮ ₩ ₪ ₭ ₤ € $