Vc6.0 compiler parameter settings

Source: Internet
Author: User

The configuration of vc6.0 compiler parameters is mainly completed on the project> Settings> C/C ++ page of the VC menu item. We can see the content in project options at the bottom of this page, which is generally as follows:

/Nologo/MDD/W3/GM/GX/Zi/OD/D "Win32"/D "_ debug"/D "_ WINDOWS"/D "_ afxdll"/D" _ MBCS "/FP" Debug/writingdlgtest. PCH "/YU" stdafx. H "/FO" Debug/"/FD" Debug/"/FD/GZ/C

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. In general, we do not directly modify these settings, but complete them through the items in the top category on this page ......
-Reprint-

Mainly through the menu items of VC Project-> Settings-> C/C ++Page. We can see the content in project options at the bottom of this page, which is generally as follows:

/Nologo/MDD/W3/GM/GX/Zi/OD/D "Win32"/D "_ debug"/D "_ WINDOWS"/D "_ afxdll"/D" _ MBCS "/FP" Debug/writingdlgtest. PCH "/YU" stdafx. H "/FO" Debug/"/FD" Debug/"/FD/GZ/C

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.

1) General: Some general settings.

  • Warning LevelUsed to control warning information. Level 1 is the most serious level;
  • Warnings as errorsHandle warning messages as errors;
  • OptimizationsCode optimization: You can perform more detailed settings in the optimizations item of category;
  • Generate browse infoIt is used to generate. SBR files, record classes, variables, and other symbolic information. You can perform more settings in the listing files item of category.
  • Debug infoGenerate debugging information:
    • None, Does not generate any debugging information (compilation is faster );
    • Line numbers onlyOnly generate debugging information for global and external symbols to the. OBJ file or. EXE file to reduce the size of the target file;
    • C 7.0-compatibleRecord all the symbols used by the debugger to The. OBJ file and. EXE file;
    • Program database, Create a. PDB file to record all debugging information;
    • Program database for "Edit & continue", Create a. PDB file to record all debugging information and support editing during debugging.


2) C ++ Language

  • Pointer-to-member representationUsed to set the sequence of class definition/reference:

    • Best-case always, Indicates that the class must have been defined before the reference class;
    • General-purpose always,?
      • Point to any class
      • Point to single-and multiple-inheritance classes
      • Point to single-inheritance classes
  • Enable Exception HandlingTo handle synchronization exceptions;
  • Enable run-time type informationForce the compiler to add code to check the object type during runtime;
  • Disable construction displacementsSet the class constructor/destructor to call the virtual function.


3)
Code Generation

  • ProcessorIndicates code command optimization, which can be80386,80486,Pentium,Pentium Pro, OrBlendIt indicates the optimization of the hybrid mode.
  • Use run-time LibraryTo specify the Runtime Library Used for running the program, one principle is that a process should not use several versions of the Runtime Library at the same time. 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.
    • Single-threaded, Single-thread release version, static connection to the libc. Lib library;
    • Debug single-threaded, Single-thread debug version, static connection libcd. Lib library;
    • Multithreaded, Multi-thread release version, static connection libcmt. Lib library;
    • Debug multithreaded, Multi-thread debug version, static connection libcmtd. Lib library;
    • Multithreaded DLL, Dynamically connect to the msvcrt. dll library;
    • Debug multithreaded DLLTo dynamically connect to the msvcrtd. dll library.
  • Calling conventionIt can be used to set the call conventions. There are three types:_ Cdecl,_ FastcallAnd_ Stdcall.
    The main differences between various call conventions are: 1. 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; 2. when a function is returned, the caller of the function cleans up the parameters pushed into the stack or the function itself. 3. and the name modification of the function name during compilation (you can see various naming methods through listing files ).
  • Struct member alignmentIt is used to specify the size of the member variables in the data structure in the memory. The data access speed varies depending on the number of digits of 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.


4)
Customize

  • Disable language extensions, Indicating that the language extensions made by Microsoft for Standard C are not used;
  • Eliminate duplicate stringsIs mainly used for string optimization (put the string in the slow filling pool to save space). This parameter makes
    Char * sbuffer = "this is a character buffer ";
    Char * tbuffer = "this is a character buffer ";
    Sbuffer and tbuffer point to the same memory space;
  • Enable function-level linkingTells the compiler to compile each function in the packaging format;
  • Enables minimal rebuildBy saving the association information to the. IDB file, the compiler only recompiles the source files modified by the latest class definition to improve the compilation speed;
  • Enable incremental compilationOnly the latest modified functions are recompiled using the information saved in the. IDB file;
  • Suppress startup banner and information messagesTo control whether the parameter is output in the output window.


5)
Listing files

  • Generate browse infoAs mentioned above. You can perform more settings here.
  • Exclude local variables from browse infoIndicates whether to put the local variable information in the. SBR file.
  • Listing file typeYou can set the content of the generated list information file:
    • Assembly-only listingGenerate only the assembly code file (. ASM extension );
    • Assembly with machine codeGenerate machine code and assembly code files (. COD extension );
    • Assembly with source codeGenerate source code and assembly code files (. ASM extension );
    • Assembly, machine code, and sourceGenerate machine code, source code, and assembly code file (. COD extension ).
  • Listing file nameThe path of the generated information file, usually in the debug or release directory. The generated file name automatically retrieves the file name of the source file.


6) Optimizations
Code optimization settings.

  • Maximize speedGenerate the fastest code;
  • Minimize sizeGenerate the minimum size program;
  • CustomizeCustom optimization. Customized content includes:
    • Assume no aliasing, Do not use aliases (Increase speed );
    • Assume aliasing implements SS function CILS, Only functions do not use aliases;
    • Global OptimizationsGlobal Optimization, such as storing frequently used variables using registers or computing Optimization in a loop, such as I =-100; while (I <0) {I + = x + y ;}will be optimized to I =-100; t = x + y; while (I <0) {I + = T ;};
    • Generate intrinsic functions, Replace some function calls with internal functions (improving the speed );
    • Improve float consistency, Floating point operation optimization;
    • Favor small code, Program (exe or DLL) Size Optimization takes precedence over code Speed Optimization;
    • Favor fast code, Program (exe or DLL) code Speed Optimization takes precedence over Size Optimization;
    • Frame-pointer Omission, No frame pointer is used to increase the function call speed;
    • Full OptimizationWhich combines several parameters to generate the fastest program code.
  • Inline Function Expansion, Inline Function Extension optimization (using inline can save the overhead of function calling and speed up the program ):
    • Disable, Do not use inline;
    • Only _ inline, Only the inline or _ inline mark before the function definition uses inline;
    • Any suitableExcept for the functions marked by inline or _ inline, the compiler "thinks" inline functions should be used.


7)
Precompiled headersPrecompiled header file settings. Pre-compilation can improve the speed of repeated compilation. Generally, VC adds some public and slightly changed header files (such as afxwin. h) To stdafx. h, this part of the Code does not have to be re-compiled every time (unless it is rebuild all ).

8) PreprocessorPre-compile. Some constants can be defined or removed.

  • Additional include directoriesYou can specify an additional include directory, which is generally relative to the directory of the project, such as../include.
Connection parameter settings
The project-> Settings-> link page of the VC menu item is used. We can see the content in project options at the bottom of this page, which is generally as follows:

/Nologo/subsystem: Windows/Incremental: yes/PDB: "Debug/writingdlgtest. PDB"/debug/machine: i386/out: "Debug/writingdlgtest.exe"/pdbtype: sept

Next, let's take a look at the various settings in category.

1) GeneralSome general settings. You can set the path and file name of the generated file, and the connected library file;

  • Generate debug infoGenerate the debug information to the. PDB file (the specific format can be set in category-> Debug );
  • Ignore all default Libraries, Discard all default database connections;
  • Link incrementally, Incremental connections are implemented by generating. ilk files to increase the speed of subsequent connections, but the files (exe or DLL) generated in this mode are usually large;
  • Generate mapfileGenerate information about the. map file record module;
  • Enable profilingThis parameter is usually used together with the generate mapfile parameter. If debugging information is generated, the. PDB file cannot be used and Microsoft format must be used.

2) customizeYou can set the database file.

  • Force file outputTo generate an output file (exe or DLL );
  • Print progress messagesTo output the progress information in the connection process to the output window.


3) debug
Set whether to generate debugging information and the format of debugging information.

  • Dubug info, The format can beMicrosoft format,Coff format (Common Object File Format)AndBoth formatsThree options;
  • Separate typesThe debug format information is stored in an independent. PDB file, or directly in the. PDB file of each source file. If selected, the latter method is used. This method is faster for debugging and startup.

4) InputYou 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 referencesYou can specify a library to connect to a specific symbol definition.

5) Output 

  • Base AddressYou 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 from this base address.
  • Entry-point symbolYou can specify the entry address of the program, which is generally a function name (and must use the _ stdcall call Convention ). 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 allocationsSet the stack size used by the Program (in decimal format). The default value is 1 MB.
  • Version InformationTell the connector to add the version number at the beginning of the EXE or DLL file.

It is worth noting that:

  1. The preceding parameters are case sensitive;
  2. Adding "-" after the parameter indicates that the parameter is invalid;
  3. Each parameter value option is represented by "*" as the default value of this parameter;
  4. You can use the "reset" button in the upper-right corner of the page to restore all default settings on the page.
Other parameter settings.

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 DLL of MFC when the MFC software is released.

2) Project-> Settings-> Debug: You can set executable files and command line parameters that run during debugging.

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 it as follows:

Description: Register com

Commands: regsvr32/S/C $ (targetpath)

Echo regsvr32 exe. Time> $ (targetdir)/$ (targetname). Trg

Outputs: $ (targetdir)/$ (targetname). Trg

4) Tools-> options-> directories: Set the include and library paths of the system.

Tips

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.

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.

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.

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.

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.