Close contact with vc6.0 Compiler

Source: Internet
Author: User

Http://www.ggstudy.com/bbs/simple/index.php? T8190.html

You may have been using VC to develop software, but you may not be familiar with this compiler. There are many reasons. In most cases, we only "use" it, instead of "Understanding" it. Because it is just a tool, we would rather focus more on the C ++ language and software design. We are used to this "pattern": creating a project, writing code, compiling, and debugging. However, the so-called: "to do good deeds, you must first sharpen your tools ". If we are better at the VC development environment, can we be more comfortable? N (4-u = L
# A: '% q5u
Let's talk less. Let's take a look at the VC processing process, which is roughly divided into two steps: Compilation and connection. After the source file is compiled and translated, all the. objfile named .objfile and the. libfile are connected to the. exe file or. dll file. Next, we will discuss the details of these two steps. ) * Z'kx1
7B (; # d
Compilation parameter settings. The project-> Settings-> C/C ++ page of the VC menu is used. We can see the content in project options at the bottom of this page, which is generally as follows: # & B @ lifecycle 7
FD # 3l
/Nologo/MDD/W3/GM/GX/Zi/OD/d Win32/D _ debug/D _ WINDOWS/D _ afxdll/D _ MBCS/fpdebug/writingdlgtest. PCH/yustdafx. h/fodebug // fddebug // FD/GZ/C b9tpzl. Y [
K,) X? = Cy
For the meaning of each parameter, refer to msdn. For example, the/nologo indicates that these settings are not displayed in the output window during compilation (we can remove this parameter to see the effect. Generally, we do not directly modify these settings, but do it through the items in the top category on this page. ; F ^ ENM
Tcabe "x
1)General: Some general settings. Warning Level is used to control warning information, where Level 1 is the most serious level; warnings as errors treats warning information as an error; optimizations is code optimization, you can perform more detailed settings in the optimizations item of category; generate browse info is used to generate. you can set more parameters in the listing files of category. Debug info, generate debugging information: None, do not generate any debugging information (compilation is faster); line numbers only, only generate debugging information of global and external symbols. OBJ file or. EXE file to reduce the size of the target file; C 7.0-compatible, record all the symbols used by the debugger. OBJ file and. EXE file; program database, create. all debugging information is recorded in the PDB file; program database for edit & continue, create. the PDB file records all debugging information and supports editing during debugging. Dr & 'z/RE3 _
Cy tafi
2)C ++ Language: Pointer_to_member representation is used to set the class definition/reference sequence. Generally, best-case always indicates that the class must have been defined before the class is referenced; Enable Exception Handling for synchronization exception handling; enable run-time type information forces the compiler to add the object type check during code execution. Disable construction displacements sets the class constructor/destructor to call virtual functions. ! Ftosg
7A} I> DMM )'
3)Code Generation: Processor indicates code command optimization, which can be 80386, 80486, Pentium, Pentium Pro, or blend. Use run-time library is used to specify the Runtime Library (single thread or multi-thread, debug version or release version) used when the program is running. One principle is, A process should not use several versions of runtime libraries at the same time. Single-threaded, static connection libc. lib Library; debug single-threaded, static connection libcd. lib Library; multithreaded, static connection libcmt. lib Library; debug multithreaded, static connection libcmtd. lib Library; multithreaded DLL, dynamic connection to msvcrt. dll library; debug multithreaded DLL, dynamic connection to msvcrtd. dll library. Multi-threaded calling is not supported when a single-threaded database is connected. connecting to a multi-threaded database requires the creation of multi-threaded applications. Calling convention can be used to set the call conventions, including __cdecl, _ fastcall, and _ stdcall. The main difference between various call conventions is that when a function is called, the function parameter is pushed from left to right into the stack or from right to left into the stack; when the function is returned, the parameters pushed into the stack are cleared by the caller of the function or by the function itself; and the name modification of the function name during compilation (you can see various naming methods through listing files ). Struct member alignment is used to specify the size of the member variables in the data structure in the memory. The data access speed varies with the alignment mode based on the number of digits in the computer data bus. This parameter is especially important for applications such as packet network transmission. It is not about the access speed, but about the precise definition of data bit. It is generally specified by # pragma pack in the program. REE/'v
? Xs3h0 "= V
4)Customize: Disable language extensions, indicating that the Language extension made by Microsoft for Standard C is not used; eliminate duplicate strings, mainly used for string optimization (put the string in the slow-filling pool to save space ), use this parameter to make 8-A = zfe
'K & ZX
Char * sbuffer = This is a character buffer; qotn = 1
Zr,) 6qp
Char * tbuffer = This is a character buffer; [ls? PC
1 ecvn
Sbuffer and tbuffer point to the same memory space. Enable function-level linking tells the compiler to compile each function in the packaging format. enables minimal rebuild saves the association information. the IDB file enables the compiler to recompile only the source files modified by the latest class definition to improve the compilation speed. Enable incremental compilation also passes. the information stored in the IDB file. Only the latest modified functions are recompiled. Suppress startup banner and information messages are used to control whether the parameters are output in the output window. [Sn !} Znks
D08fk * DJ
5)Listing files: Generate browse info has been mentioned above. You can perform more settings here. Exclude local variables from browse info indicates whether to put information about local variables in the. SBR file. The listing file type can be used to set the content of the generated list information file: Assembly-only listing only generates the assembly code file (. ASM extension); Assembly with machine code to generate machine code and assembly code files (. cod extension); Assembly with source code to generate source code and assembly code files (. ASM extension); Assembly, machine code, and source generate machine code, source code, and assembly code file (. cod extension ). The listing file name is the path of the generated information file. Generally, it is in the debug or release directory. The generated file name automatically retrieves the file name of the source file. } + _ D v $
Y '6lqs2' n
6)Optimizations: Code optimization settings. You can select maximize speed to generate the fastest code, mini-Mize size to generate the smallest program, or custom Optimization of mimize. Customized content includes: &, lat51] d
6! Jkshc0
Assume no aliasing, no alias (Increase speed); 'm2 'V/R/
Srgnl "SP
Assume aliasing implements SS function CILS. Only aliases are not used inside the function. | zjvlw0 <8
X] {kW "(
Global optimizations: Global Optimization. For example, frequently used variables are saved using registers, or computing optimization in the loop, such as; QB % "M" af
Ne/hbdz3rr
I =-100; T8 $ E [7j
# Ixicy
While (I settings-> link page. We can see the content in project options at the bottom of this page, which is generally as follows: 4]? <Xfz
Lf *) D; AE]
/Nologo/subsystem: Windows/Incremental: yes/PDB: Debug/writingdlgtest. PDB/debug/machine: i386/out: Debug/writingdlgtest.exe/pdbtype: Sept @ | MZ $
TOF [Z
Next, let's take a look at the various settings in category. (Ot. JT
R % I gogk}
1)General: Some general settings. You can set the generated file path and file name, connect to the library file, Generate debug info, and Generate debug information. PDB file (the specific format can be set in category-> Debug); ignore all default libraries, discard all default library connections; link incrementally, through generation. the ilk file implements incremental connections to increase the speed of subsequent connections, but the files (exe or DLL) generated in this mode are large; generate mapfile, generate. the map file records information about the module. Enable profiling, this parameter is usually used together with the generate mapfile parameter, and cannot be used if debug information is generated. PDB file, and Microsoft format must be used. . 'O "M8
EdIg0-v.
2)Customize: You can set the database file. Force file output, which forces the generation of output files (exe or DLL); print progress messages, which can output the progress information in the connection process to the output window. EQ "> A" % 2>
X06 % htio
3)Debug: Sets whether to generate debugging information and the format of debugging information. The format can be Microsoft format, coff format (Common Object File Format), and both formats. Separate types indicates that the debug format information is independent. PDB files are stored directly in the source files. in the PDB file. If selected, the latter method is used. This method is faster for debugging and startup. ; D3 n |
LZ we] NQ ~
4)Input: You can specify the database file to be connected and discard the database file to be connected. You can also add an additional library file directory, which is generally relative to the directory of the project, such as./lib. Force symbol references. You can specify a library to connect to a specific symbol definition. HQ re:
K) d <5sqe08
5)Output: Base address can change the default base address of the program (the default base address of the EXE file is 0x400000, and the default DLL is 0x10000000). When the operating system loads a program, it always tries to start with this base address. Entry-point symbol can specify the entry address of a program. Generally, it is a function name (and the _ stdcall call Convention must be used ). Generally, for Win32 programs, the EXE entry is winmain and the DLL entry is dllentrypoint. It is best to enable the connector to automatically set the program entry point. By default, it is implemented through a C Runtime library function: the console program uses maincrtstartup (or wmaincrtstartup) to call the main (or wmain) function of the program; windows programs use winmaincrtstartup (or wwinmaincrtstartup) to call winmain (or wwinmain, which must use the _ stdcall call Convention) of the program ); DLL uses _ dllmaincrtstartup to call the dllmain function (the _ stdcall call Convention must be used ). Stack allocations, used to set the stack size used by the Program (in decimal format). The default value is 1 MB. Version Information tells the connector to add the version number to the start part of the EXE or DLL file. T * TX 'o
G {} uxc | x
It is worth noting that the above parameters are case-sensitive. Adding "-" after the parameter indicates that this parameter is invalid; each parameter value option is represented by "*" as the default value of this parameter. You can use the "reset" button in the upper-right corner of the page to restore all default settings on this page. , 38C _ 9iz
W2 "V8: % 16
Other parameter settings. O6w/
Y = ~ XTi
1) Project-> Settings-> General, you can set the method for connecting to the MFC Library (static or dynamic ). If it is a dynamic connection, do not forget to include the mfc dll when your software is released. W ,? 3ww
H ^ Tlas>
2) Project-> Settings-> Debug: You can set executable files and command line parameters that run during debugging. [B $ F &-O <
] ~ % 6u
3) Project-> Settings-> Custom Build, you can set to automatically execute some operations after the compilation/connection is successful. When writing COM, you want VC to automatically register the compiled COM file. You can set g'hhzbbh as follows:
J7 'jsq ^'
Description: Register com 5.6a/h/
Ngu "xm1 #} H
Commands: regsvr32/S/C $ (targetpath) S = T = ck J
Anfgqr I
Echo regsvr32 exe. Time> $ (targetdir)/$ (targetname). Trg, iexcryxk
UB/5b? M (
Outputs: $ (targetdir)/$ (targetname). Trg ib8l [fa
"Q" "X) ST
4) Tools-> options-> directories: Set the include and library paths of the system. ? Pu @ RW -{
Da2by) 0w |
TipsSt'8 L] C7
7 cdmvx
1) Sometimes, during compilation, the computer suddenly shuts down illegally (maybe someone accidentally hits the power or your memory is unstable ). After you restart the machine, open the project and re-compile it. Then, the VC will crash. You may think that your VC compiler is broken, but it is not (you should try to compile other projects !), You only need to delete the project's. NCB,. Opt,. APs,. CLW files, and all the files under the debug and release directories, and then recompile them. R0? $ *? _
X-2 {? 7 |
2) If you want to share your source code project with others, but copying the entire project is too large. You can delete the following files:. DSW,. NCB,. Opt,. APs,. CLW,. PLG, and all files in the debug and release directories. '0ep? -;
Jf ~ 87's
3) when your workspace contains multiple projects, you may not be able to intuitively and intuitively see which project is the current one. You can set the settings as follows: Tools-> options-> Format, select workspace window in category, and change its default font (for example, set it to fixedsys. Brbfg86/
} Yxxy22
4) how to change the name of an existing project? Turn off the project. Open the. DSP file in text format and replace the original project name. ^ A =. j) Gy |
Ivtix1o o
5) vc6 is useful for smart prompting of class members, but sometimes it fails. You can close the project first. CLW and. delete NCB and re-open the project. Click View> classwizard in the menu item. In the displayed dialog box, click "add all" and rebuild all. Should be able to solve the problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.