zoukankan      html  css  js  c++  java
  • Stlport Tips

    //z 2012-6-8 17:54:59 PM is2120@csdn.T2248944666
    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.)

    public member function

    std::string::c_str

    <string>
    const char* c_str ( ) const;
    Get C string equivalent
    Generates a null-terminated sequence of characters (c-string) with the same content as the string object and returns it as a pointer to an array of characters.

    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

    none

    Return Value

    Pointer to an internal array containing the c-string equivalent to the string content.

    public member function

    std::string::data

    <string>
    const char* data() const;
    Get string data
    Returns a pointer to an array of characters with the same content as the string.

    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

    none

    Return Value

    Pointer to an internal array containing the same content as the string.
  • 相关阅读:
    vscode已有64位版本。
    git代码回滚的两种选择
    代码维护的问题
    草珊瑚理解IFC(inline formatting context)
    nodejs的dependency.md
    如何实现在H5里调起高德地图APP?(下)
    如何实现在H5里调起高德地图APP?(上)
    酸奶妈妈再次回归~
    【从零开始学】如何在安卓平台上实现定位?
    如何将四大名著和地图相结合?
  • 原文地址:https://www.cnblogs.com/IS2120/p/6745885.html
Copyright © 2011-2022 走看看