Home | History | Annotate | Download | only in doc
      1                            Content
      2 
      3 Q1 About STLport and availability
      4 
      5 Q1.0 What is STLport?
      6 Q1.1 What are the benefits from using STLport?
      7 Q1.2 What versions of STLport are available?
      8 Q1.3 Where is the documentation or user guide?
      9 Q1.4 What is the version policy?
     10 
     11 Q2 General
     12 
     13 Q2.0 Do I need a C++ compiler?
     14 Q2.1 Do I need runtime libraries from C++ compiler?
     15 Q2.2 Can I use containers and algorithms from STLport and iostreams from
     16 library that ship with my compiler?
     17 Q2.3 Can I mix STL implementations in my project?
     18 Q2.4 When I switch to STLport in my application, I get errors. Is STLport
     19 so bad?
     20 
     21 Q3 Building
     22 
     23 Q3.0 On my XXXX Linux n.n g++ headers are in /usr/include/g++, but they
     24 are looked for in /usr/include/3.3.1. Is it a STLport bug?
     25 Q3.1 Do I need to build library to use STLport?
     26 Q3.2 During library compilation with MS VC++ 6.0 I see following error report:...
     27 Q3.3 Has anybody succeeded building STLport on OS Y with compiler K n.n?
     28 Q3.4 Does STLport support cross-compilation?
     29 
     30 Q4 Installation
     31 
     32 Q4.1 I tried "make -f gcc.mak install", but it install nothing into
     33 /usr/local/. How I can install headers into /usr/local/include and
     34 libs into /usr/local/lib?
     35 
     36 Q5 Bug report
     37 
     38 Q5.0 I found a bug, how can I report about it?
     39 
     40 Q6 Design
     41 
     42 Q6.0 In STLport, files like locale.h, setjmp.h, stdlib.h, etc.,
     43 do nothing except include native headers. Why are these files present in STLport?
     44 Q6.1 Is STLport a replacement for headers and libraries that shipout
     45 with compiler?
     46 Q6.2 My tool detects memory leaks in applications with STLport. Is this leak
     47 from STLport?
     48 Q6.3 When running unit tests, I have errors in LocaleTest test fixture, how bad
     49 is it?
     50 Q6.4 set or multiset iterators are immutable like const_iterators, why ?
     51 
     52                            Answers
     53 
     54 ========================================================================
     55 
     56 Q1.0 What is STLport?
     57 A1.0 STLport is an implementation of the C++ Standard Library, as described 
     58 in the INTERNATIONAL STANDARD ISO/IEC 14882:1998(E) and latest
     59 ISO/IEC 14882:2003(E).
     60 
     61 ========================================================================
     62 
     63 Q1.1 What are the benefits from using STLport?
     64 
     65 A1.1
     66   - For multiplatform/multicompilers project a coherent Standard Library
     67 implementation.
     68   - An easy to use STL safe mode detecting bad use of containers and
     69 iterators.
     70   - Some original optimizations: template expression for string
     71 concatenation, short string optimization, move semantic for STL containers
     72 combination like vector of vector, an efficient std::allocator.
     73 
     74 ========================================================================
     75 
     76 Q1.2 What versions of STLport are available?
     77 
     78 A1.2
     79 
     80 ========================================================================
     81 
     82 Q1.3 Where is the user guide?
     83 
     84 A1.3 There is no real user guide for the moment. You can find some information
     85 in README files in doc folder. As STLport is a C++ Standard library
     86 implementation you might find information you need at the following
     87 locations:
     88   - The ISO/IEC 14882:2003 document you can buy for a very cheap price.
     89   - For STL containers you can use SGI documentation (http://www.sgi.com/tech/stl/).
     90     Beware however, STL described in this document is not identical to the
     91     Standardized version described in ISO/IEC. This documentation can be very
     92     useful for STLport extensions like hash containers (hash_map, hash_set...)
     93   - You can also use the documentation coming with your compiler as most
     94     of the information will also apply to STLport. Take care to description
     95     reported as 'implementation specific'.
     96 
     97 ========================================================================
     98 
     99 Q1.4 What is the version policy?
    100 
    101 A1.4 STLport version information contains three numbers like '5.1.0'. '5'
    102 is the major version number, '1' is the minor and '0' is the patch level.
    103 Policy for this numbers are:
    104   - changes in major version number: radical modification, new era.
    105   - changes in minor version number: significant changes, new features,
    106     changes in interface part; switching to an STLport library with a different
    107     minor version require recompilation of all modules depending on it.
    108   - changes in patch level: bugfixes; we keep in mind binary compatibility,
    109     but really can't strongly guarantee it; switching to an STLport library
    110     with different patch level do not require rebuild of modules---rebuilding and
    111     installing the STLport libraries should work; however, as STLport contains
    112     a lot of template code, you should pay attention to fact that all you modules
    113     was build with SAME STLport headers---otherwise problems possible;
    114     recompilation of one part with only rebuilding STLport might not be enough
    115     to get all the fixes in your application so even in this case rebuilding
    116     your modules is advised.
    117 
    118 ========================================================================
    119 
    120 
    121 Q2.0 Do I need a C++ compiler?
    122 
    123 A2.0 STLport is a C++ library. So the answer is 'yes, you do'.
    124 
    125 ========================================================================
    126 
    127 Q2.1 Do I need runtime libraries from C++ compiler?
    128 
    129 A2.1 In any case, the C++ language support from compiler is required
    130 for STLport (operators new, delete, RTTI, exceptions support). That's why
    131 in most cases you need some runtime libraries from the C++ compiler.
    132 
    133 ========================================================================
    134 
    135 Q2.2 Can I use containers and algorithms from STLport and iostreams from
    136 the library that ships with my compiler?
    137 
    138 A2.2 The short answer is 'No'.
    139 
    140 Indeed co-existence of two implementations possible, but this required
    141 a lot of knowledge as about both implementations, as about compiler and
    142 linkage. This issues should be taken into account both within STL library and
    143 during library usage. In common you can't use both implementation
    144 in the same namespace. So you should separate STL implementations into
    145 different namespaces. But due to absent of compilers that has full-featured
    146 support of Argument Dependent Lookup (ADL) (aka Koenig Lookup), you have no
    147 possibilty to select one or another implementation.
    148 
    149 ADL problem.
    150 
    151 In wrapper mode, all std references are replaced, thanks a simple macro,
    152 by the stlp_std namespace. Everything from the native compiler std namespace
    153 is injected to the stlp_std namespace with many using std::* directives.
    154 
    155 The problem arise when you specialized a standard class for one of your
    156 user types. You do it within the std namespace that, in wrapper mode
    157 becomes the stlp_std namespace. Then this specialization is just invisible
    158 from the native std namespace and won't be used.
    159 
    160 Things are somewhat worse: the problem arises even without any explicit
    161 specializations. It is not a bug, but the fact that old compilers just
    162 did not tried to find functions in the namespaces where arguments' classes
    163 are defined (indeed no compilers with full-featured support of ADL yet).
    164 
    165 Mix implementation via library.
    166 
    167 Let's reduce all the complexity of STLport to some very simple example:
    168 
    169 namespace std {
    170 
    171 class string
    172 {
    173   public:
    174     class iterator { };
    175 
    176     iterator begin();
    177     iterator end();
    178 };
    179 
    180 template<class I, class T>
    181 void find(I begin, I end, T value);
    182 
    183 } // namespace std
    184 
    185 
    186 namespace stlport {
    187 
    188 using std::string;
    189 
    190 template<class I, class T>
    191 void find(I begin, I end, T value);
    192 
    193 void gee()
    194 {
    195   string s;
    196   find(s.begin(), s.end(), 10);
    197 }
    198 
    199 } // namespace stlport
    200 
    201 
    202 When a compiler supporting ADL finds the call to `find' within gee() function
    203 it should examine both namespace `stlport' and namespace `std' for
    204 the presence of `find'. It is caused by the fact that s.begin() returns
    205 object of type `std::string::iterator' which obviously defined in namespace
    206 `std' and the heart of ADL is finding functions not only within namespaces
    207 where the call is being made but also in the namespaces where the classes
    208 of arguments are defined...
    209 
    210 So, in our example compiler ends with two templates satisfying the call
    211 `find(s.begin(), s.end(), 10)': `std::find' and `stlport::find'.
    212 Since compiler can not choose any one of them it reports ambiguity.
    213 
    214 There is another aspect of mix implementations.
    215 Let's consider following code:
    216 
    217 a.h:
    218 
    219 #include <string>
    220 
    221 class A {
    222   public:
    223     A() {}
    224 
    225     void push( const string s );
    226     
    227     string _str;
    228 };
    229 
    230 a.cpp:
    231 
    232 #include "a.h"
    233 
    234 void A::push( const string s )
    235 {
    236   _str = s;
    237 }
    238 
    239 
    240 b.cpp:
    241 
    242 #include "a.h"
    243 
    244 string s;
    245 A a;
    246 
    247 void gee()
    248 {
    249    a.push( s );
    250 }
    251 
    252 Now build library from a.cpp with string implementation Impl1;
    253 then build application with b.cpp that use string implementation Impl2,
    254 and link with mentioned above library. Compiler will pass. Linker may 
    255 pass too. But your application will crash (or randomly crash) either on
    256 call a.push, or on assignment _str = s. This is evident here, but not
    257 evident in real applications.
    258 
    259 The conclusion is: "Using Wrapper mode is very hard and we removed support
    260 for it".
    261 
    262 ========================================================================
    263 
    264 Q2.3 Can I mix STL implementations in my project?
    265 
    266 A2.3 Yes you can but each implementations will rely in its own namespace
    267 with no direct interaction between them. You will first need to correctly
    268 configure STLport thanks to 2 macros in user_config.h file.
    269 - _STLP_DONT_REDEFINE_STD tells STLport not to define the std macro that is
    270 used to replace std reference in your code with STLport namespace.
    271 - _STLP_WHOLE_NATIVE_STD tells STLport to always include native header each
    272 time a Standard header is included in your code.
    273 
    274 Here is a small code sample that do not require any modification in STLport
    275 install:
    276 
    277 #define _STLP_DONT_REDEFINE_STD
    278 #define _STLP_WHOLE_NATIVE_STD
    279 
    280 #include <string>
    281 
    282 void foo()
    283 {
    284    std::string std_str("std");
    285    stlport::string stlport_str("stlport");
    286    stlport_str.append(std_str.begin(), std_str.end());
    287    // Following is wrong because there is no assignment
    288    // operator for stlport::string on std::string.
    289    //std_str = stlport_str;
    290 }
    291 
    292 Note: You can use 'std' iterators from native implementation in STLport
    293 template methods like in the 'stlport_str.append' method call above because
    294 STLport is adding the necessary code to interpret native iterators like
    295 STLport iterators. You won't be able however to do the opposite as native
    296 implementation do not know anything about STLport iterators.
    297 
    298 
    299 ========================================================================
    300 
    301 Q2.4 When I switch to STLport in my application, I get errors. Is STLport
    302 so bad?
    303 
    304 A2.4 Before you post such message, please, check STLport WHITHOUT YOUR code:
    305   - build STLport library
    306   - build STLport unit tests
    307   - run STLport unit tests
    308 If any of above steps fail, please, make sure that you carefully followed
    309 build instructions (in most cases you definitely should reread
    310 instructions and check that you correctly unpack archive in case you see
    311 'file not found' message). Build instructions you can found in files
    312 INSTALL, doc/README.*, build/README*, build/test/unit/README*.
    313 If you are sure, submit bug report here:
    314 https://sourceforge.net/projects/stlport
    315 Don't forget to describe your operational environment, compiler version and
    316 STLport version.
    317 
    318 ========================================================================
    319 
    320 Q3.0 On my XXXX Linux n.n g++ headers are in /usr/include/g++, but they
    321 are looked for in /usr/include/3.3.1. Is it a STLport bug?
    322 
    323 A3.0 Path to native compiler headers for GCC correspond to default path
    324 after build/install compiler (i.e. paths from compiler origo).
    325 Package maintainers can use any path by own taste---we can't satisfy
    326 variety of distributions/packages.
    327 
    328 So you can:
    329  - fix path in stlport administration config file stlport/stl/config/host.h, 
    330    see _STLP_NATIVE_INCLUDE_PATH macro and related.
    331  - create a link to the native compiler headers like expected by STLport
    332  - make request to package maintainer
    333  - build and install compiler
    334 
    335 Note: Starting with version 5.2, STLport uses the include_next preprocessing
    336 command to access native headers so you shouldn't experiment this problem
    337 anymore when this feature is supported by your compiler preprocessor.
    338 
    339 ========================================================================
    340 
    341 Q3.1 Do I need to build a library to use STLport?
    342 
    343 A3.1 You may omit usage (and, thus building) STLport library, but in this
    344 case you can't use iostreams, locale, complex.
    345 
    346 ========================================================================
    347 
    348 Q3.2 During library compilation with MS VC++ 6.0 I see following error report:
    349 
    350 C:\Program Files\Microsoft SDK\Include\.\winbase.h(1123) : error C2733: second C linkage of overloaded function 'InterlockedIncrement' not allowed
    351         C:\Program Files\Microsoft SDK\Include\.\winbase.h(1121) : see declaration of 'InterlockedIncrement'
    352 C:\Program Files\Microsoft SDK\Include\.\winbase.h(1130) : error C2733: second C linkage of overloaded function 'InterlockedDecrement' not allowed
    353         C:\Program Files\Microsoft SDK\Include\.\winbase.h(1128) : see declaration of 'InterlockedDecrement'
    354 C:\Program Files\Microsoft SDK\Include\.\winbase.h(1138) : error C2733: second C linkage of overloaded function 'InterlockedExchange' not allowed
    355         C:\Program Files\Microsoft SDK\Include\.\winbase.h(1135) : see declaration of 'InterlockedExchange'
    356 
    357 A3.2 You have a Platform SDK installed. Uncomment line
    358 #define _STLP_NEW_PLATFORM_SDK 1
    359 in the file stlport/stl/config/user_config.h. There is no way to detect SDK
    360 presence during preprocessor stage, which is why you have to make this
    361 change manually.
    362 
    363 ========================================================================
    364 
    365 Q3.3 Has anybody succeeded building STLport on OS S with compiler K n.n?
    366 
    367 A3.3 See report about results of regression tests here: build/test/unit/STATUS.
    368 
    369 ========================================================================
    370 
    371 Q3.4 Does STLport support cross-compilation?
    372 
    373 A3.4 In case of GCC, use something like following sequence:
    374 
    375   (./configure --target=${CROSSTARGET}; cd build/lib; \
    376      export PATH=${BASECROSS}/bin:${PATH}; make -f gcc.mak install-release-shared)
    377 
    378 where CROSSTARGET is GCC's cross prefix (something like 'i586-pc-linux-gnu',
    379 if C++ cross compiler named as 'i586-pc-linux-gnu-c++'), BASECROSS is base of
    380 cross-compiler's location (i.e. ${BASECROSS}/bin in case above is a location
    381 of 'i586-pc-linux-gnu-c++').
    382 
    383 In case of non-GCC crossecompilers, we need hands-made target system identification.
    384 The sample of such compiler (supported by STLport) is MetroWerks Codewarrior
    385 for Novell Netware (mwccnlm).
    386 
    387 ========================================================================
    388 
    389 Q4.1 I tried "make -f gcc.mak install", but it installs nothing into
    390 /usr/local/. How I can install headers into /usr/local/include and
    391 libs into /usr/local/lib?
    392 
    393 A4.1 Installation in any system-wide place is issue of either 'package builder'
    394 or system administrator. He/she should be familiar with building package
    395 procedure and/or understand where headers and libraries should be situated.
    396 The place choice not issue of STLport.
    397 
    398 You can just use
    399 
    400 (cd ${STLPORT_SRC}/lib; tar cf - . ) | (cd ${TARGET_LIB_DIR}; tar xf - ); \
    401  (cd ${STLPORT_SRC}; tar cf - stlport) | (cd ${TARGET_INCLUDE_DIR}; tar xf - )
    402 
    403 Sometimes we will think about 'make install', but not now.
    404 
    405 
    406 ========================================================================
    407 
    408 Q5.0 I found a bug, how I can report about it?
    409 
    410 A5.0 
    411   0. Ensure that this is really a bug (standard violation, incorrect
    412      behaviour with correct usage).
    413   1. Ensure that bug is in STLport, not in your code (you can use _STLP_DEBUG
    414      for that, see stlport/stl/config/user_config.h).
    415   2. Ensure that you correctly built STLport---build and run unit tests
    416      (build/test/unit) first with default settings, then with your settings
    417      (if you changed any).
    418   3. Write a short test that demonstrates the bug.
    419   4. Make sure that this test case is really new, i.e. not covered by unit 
    420      tests (test/unit/*).
    421   5. Compare your results with reported runs of unit tests (build/test/unit/STATUS).
    422   6. Write bug description and test here
    423      
    424      https://sourceforge.net/projects/stlport
    425 
    426      DON'T FORGET TO DESCRIBE:
    427 
    428        - OPERATIONAL ENVIRONMENT
    429        - COMPILER VERSION
    430        - STLPORT VERSION
    431        - RESULT OF UNIT TESTS
    432 
    433      Keep in mind, that your bug MUST be reproduced by other people, so give
    434      enough information (but compactly, give only essential information).
    435 
    436 ========================================================================
    437 
    438 Q6.0 In STLport files like locale.h, setjmp.h, stdlib.h, etc., do 
    439 nothing except include native headers. Why are these files present in STLport?
    440 
    441 A6.0 Sometimes native C headers are using C++ ones or are refering
    442 to the std namespace. That's why, if stddef was absent in STLport, then
    443 
    444 #include <string>
    445 #include <stddef.h>
    446 
    447 may cause problem in following code, because std redefined in the end of
    448 <string> header, and std may be used in stddef.h:
    449 
    450 __BEGIN_NAMESPACE_STD
    451 ....
    452 __END_NAMESPACE_STD
    453 
    454 where __BEGIN_NAMESPACE_STD is defined as 'namespace std {'.
    455 To avoid this, STLport has stddef.h header and provide correct masquerade
    456 for std.
    457 
    458 ========================================================================
    459 
    460 Q6.1 Is STLport a replacement for headers and libraries that shipout
    461 with compiler?
    462 
    463 A6.1 In general no. In any case C++ language support from compiler is required
    464 for STLport (operators new, delete, RTTI, exceptions support). STLport also
    465 uses 'native' headers and libraries to take interface to system functions and
    466 variables.
    467 
    468 ========================================================================
    469 
    470 Q6.2 My tool detects memory leaks in application with STLport. Is this leak
    471 from STLport?
    472 
    473 A6.2 In most cases these are 'pseudo memory leaks' that some tools 
    474 wrongly detect.
    475 
    476 In the default compile of STLport, the node allocator is used to allocate
    477 internal memory. The node allocator works by pre-allocating a large chunk of
    478 memory and handing out small memory blocks. The memory chunk is not freed
    479 during running an application that uses STLport (i.e. it is not returned to 
    480 the system, but reused inside application). 
    481 See also http://www.sgi.com/tech/stl/alloc.html
    482 
    483 There are tools like BoundsChecker, Purify or Valgrind that check for memory
    484 leaks, for memory that isn't freed when no longer used. These tools may report
    485 false memory leaks when one uses STLport's node allocator. The memory chunk is
    486 normally freed at application end, but the memory checkers usually report memory
    487 leaks before that point. Another memory problem might be reported when you use
    488 shared libraries (e.g. DLL, this problem specific for Windows DLL model) that
    489 uses STLport internally and are statically link to it. If memory is allocated in
    490 a dll and released in an other then the STLport node allocator will keep the
    491 released memory for a future use. If you do not use this memory then your
    492 application global memory consumption will grow until the app crash even if there
    493 is no real memory leak. This is why you should always use a coherent configuration
    494 everything in dll or everything in static lib.
    495 
    496 There are ways to remove the pseudo memory leaks (since the memory is properly
    497 freed at the end of the program, the leaks are just pseudo-ones). You could use
    498 another allocator that is used in STLport. Open the file
    499 "./stlport/stl/config/host.h" and uncomment either one of the following:
    500 
    501 
    502    _STLP_USE_NEWALLOC   enables a simple allocator that uses "new/delete"
    503    _STLP_USE_MALLOC     enables a simple allocator that uses "malloc/free"
    504 
    505 The new/delete allocator has the advantage of giving an entry point to track
    506 memory starvation, see set_new_handler in your compiler doc or the C++ Standard
    507 for more information.
    508 
    509 Alternatively you can define the following symbol, just uncomment it in
    510 "./stlport/stl/config/host.h".
    511 
    512    _STLP_LEAKS_PEDANTIC
    513 
    514 The symbol forces freeing all memory chunks. Also see the comments around the
    515 symbol in the config file.
    516 
    517 Note that you have to recompile STLport AND your application and all of your
    518 dependent libraries if you make any change to the file!
    519 
    520 There are also some defines that help in debugging memory problems in STLport.
    521 In _STLP_DEBUG mode, just also define the following symbols, either in
    522 "./stlport/stl/config/user_config.h" or in your project settings:
    523 
    524    _STLP_DEBUG_ALLOC
    525    _STLP_DEBUG_UNINITIALIZED
    526 
    527 You don't need to rebuild STLport for these options, but you have to rebuild
    528 your application and all of your dependent libraries if you make any change to
    529 the file.
    530 
    531 ========================================================================
    532 
    533 Q6.3 When running unit tests, I have errors in LocaleTest test fixture, how bad
    534 is it?
    535 
    536 A6.3 Failures in LocaleTest tests do not mean that your platform/compiler is not
    537 fully supported by STLport. Platform independant localization tests are very hard
    538 to write as Standard localization API has not been design to make unit test easy.
    539 In STLport unit tests suite we have hard coded some expected values. Those values
    540 depends on your OS configuration explaining why sometimes the tests are failing.
    541 
    542 ========================================================================
    543 
    544 Q6.4 set or multiset iterators are immutable like const_iterators, why ?
    545 
    546 A6.4 With set or multiset associative containers or even newly introduced
    547 tr1::unordered_set and tr1::unordered_multiset key is confuse with data. It
    548 means that modifying the data is also modifying the key. Modifying the key
    549 might corrupt the container internal data structure so STLport prefer to
    550 make this problem obvious and only return a const access to the key with
    551 immutable iterators. Your solutions are:
    552 - prefer map/multimap and split the key and the data
    553 - use const_cast when you want to change a set/multiset element.
    554 
    555