Author: dawn (Morning) Keywords: C STL source: original [statement] For copy, distribute, please attach this statement, thank you. Original: http://morningspace.51.net/, MOYINGZZ@etang.com This article extracts self-writer self-writer "C STL easy guidance", and briefly introduces some details of running a STL program in a specific C compiler environment. And provide some solutions that may encounter problems, suitable for C fans reading of STL programs yet. This is selected as an example of Microsoft Visual C 6.0 and Borland C Builder 6.0 currently under Windows platform. Although Visual C 6.0 is not very good for the latest ANSI / ISO C standards. However, Visual C .NET (that is, VC7.0) has improved in this regard. You can use a variety of ways to run a STL program, such as under Visual C , you can compile running directly in the DOS command line, or you can use the console application in the VC IDE. The situation is similar to C Builder. For Visual C , if you are in the DOS command line, you first need to find its compiler. Assuming your Visual C is under C: / Program Files / Microsoft Visual Studio / VC98, the path where its compiler should be C: / Program Files / Microsoft Visual Studio / VC98 / BIN, where you can find Cl.exe file. Please add / gx and / mt parameters when compiling. If everything is normal, the result will generate an executable. As shown below: CL / GX / MT First_STL_PRG.CPP The former parameters are used to inform the compiler to allow exception handling. The abnormality processing mechanism (ie Try ... throw ... catch syntax) is used in the PJ Plauger STL, so this parameter should be added, otherwise there will be the following warning information: Warning C4530: C Exception Handler Used, But Unwind Semantics Are Not Enabled. The latter parameter is used to support the program to support multithreading, which requires the libcmt.lib library file when link. However, P. J. Plauger STL is not a thread safe (Thread Safety). If you use STL implementations like Stlport in a VC environment, you need to add this parameter because stlport is a thread. If you can choose a console application when you create a new project in an IDE environment. As for the settings of those parameters, they can be done by setting compilation options in the settings feature in the Project function menu item [ALT F7].
Sometimes, when compiling STL programs in the IDE environment, the following warning may occur: Warning C4786: '...': Identifier Was Truncated to '255' Characters in The Debug Information This is because the compiler compiles in the debug state, The identifier length that appears in the program is limited to 255 characters. If the maximum length is exceeded, these identifiers cannot be viewed and calculated during the debug phase. In a large number of template functions and template classes in the STL program, the compiler When instanting these content, the identifier generated after expanding is long (there will be more than 1,000 characters!). If you want to know this Warning, it is very simple. In the program, add the following line code: Vector
However, it is best not to be lucky. If you use the way of writing after the development, both compilers will not give you a love. Ok, please forgive my swap, now you can feel the truly unique charm of the STL, I wish you good luck! Note: This article has been posted on 9CBS, view related comments, please hereby: http://morningspace.51.net/Document/computer/Plhowtorunstl.xml