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