Vc6.0 compiler parameter settings

Source: Internet
Author: User
Tags aliases

Vc6.0 compiler parameters are mainly set through the menu items of VC
Project-> Settings-> C/C ++ page. We can see the bottom project of this page
The content in options 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 won't
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 won't
You can directly modify these settings through the items in the top category on this page.

1)
General
: Some general settings.

  • Warning Level
    Used to control warning information. Level 1 is the most serious level;
  • Warnings as errors
    Handle warning messages as errors;
  • Optimizations
    Code optimization, which can be included in the optimizations item of category
    More fine-grained settings;
  • Generate browse info
    Used to generate. SBR files, record class, variables, and other symbolic information.
    Set more settings in the listing files item of category.
  • Debug info
    Generate debugging information:

    • None
      , Does not generate any debugging information (compilation is faster );
    • Line numbers only
      Only generate global and external debugging information to the. OBJ file or. EXE file, reduce
      Size of the target file;
    • C 7.0-compatible
      Record 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
      Record all debugging information and support editing during debugging.


2) C ++ Language

  • Pointer-to-member representation
    Used to set the sequence of class definition/reference
    System:

    • 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 Handling
    To handle synchronization exceptions;
  • Enable run-time type information
    Force the compiler to add code at runtime
    Row object type check;
  • Disable construction displacements
    Set class constructor/destructor call
    Virtual function problems.


3)

Code Generation

  • Processor
    Indicates code command optimization, which can be80386
    ,80486
    ,Pentium
    ,Pentium
    Pro

    , OrBlend
    It indicates the optimization of the hybrid mode.
  • Use run-time Library
    To specify the Runtime Library Used for running the program, one principle is:
    Processes do not use several versions of runtime libraries 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 DLL
      To dynamically connect to the msvcrtd. dll library.
  • Calling convention
    It can be used to set the call conventions. There are three types:_ Cdecl
    ,_ Fastcall
    And_ Stdcall
    .
    The main differences between various call conventions are as follows: 1. When a function is called, whether 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. Name the function name during compilation (you can use listing
    Files ).
  • Struct member alignment
    It is used to specify the size of the member variables in the data structure in the memory by several bytes.
    Alignment: based on the number of digits of the computer data bus, the data access speed varies with Alignment Methods. This parameter is especially important for applications such as data packet network transmission, not for the speed of access, but for the accuracy of data bit
    Define the problem, which 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 strings
    Is mainly used for string optimization (put the string in the slow filling pool ).
    To save space), use this parameter to make

    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 linking
    Tells the compiler to compile each function according to the packaging format
    Translation;
  • Enables minimal rebuild
    By saving the association information to the. IDB file
    The source files modified by the new class definition are recompiled to increase the compilation speed;
  • Enable incremental compilation
    And the information stored in the. IDB file,
    Only the latest modified functions are recompiled;
  • Suppress startup banner and information messages
    ,
    Used to control whether parameters are output in the output window.


5)

Listing files

  • Generate browse info
    As mentioned above. You can perform more settings here.
  • Exclude local variables from browse info
    Indicates whether
    Put the information of some variables in the. SBR file.
  • Listing file type
    You can set the content of the generated list information file:

    • Assembly-only listing
      Generate only the assembly code file (. ASM extension );
    • Assembly with machine code
      Generate machine code and assembly code files (. COD extension );
    • Assembly with source code
      Generate source code and assembly code files (. ASM extension );
    • Assembly, machine code, and source
      Generate machine code, source code, and assembly code files
      (. COD extension ).
  • Listing file name
    The path of the generated information file, which is generally the debug or release directory.
    The generated file name automatically retrieves the file name of the source file.


6) Optimizations

Code optimization settings.

  • Maximize speed
    Generate the fastest code;
  • Minimize size
    Generate the minimum size program;
  • Customize
    Custom 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 Optimizations
      Global Optimization. For example, frequently used variables are saved using registers or computation in a loop.
      Optimization, 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 Optimization
      Which combines several parameters to generate the fastest program code.
  • Inline Function Expansion
    , Three optimizations of Inline Function Extension (using inline can save letters
    Number of call overhead to speed up the program ):

    • Disable
      , Do not use inline;
    • Only _ inline
      , Only the inline or _ inline mark before the function definition uses inline;
    • Any suitable
      Except for the functions marked by inline or _ inline, the compiler "thinks" inline functions should be used.
      All functions use inline.


7)

Precompiled headers
Precompiled header file settings. Pre-compilation can improve repeated Compilation
Speed. Generally, VC puts some common and slightly changed header files (such as afxwin. h) in stdafx. H. This part of Code does not have to be re-compiled every time (unless it is
Rebuild all ).

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

  • Additional include directories
    , You can specify an additional include directory, which is generally a phase
    For the directory of this project, such as ../include.
    Connection parameter settings

    The project-> Settings-> link page of the VC menu item is used. We can see the bottom of this page
    The content in project options 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) General
    Some general settings. You can set the path and file name of the generated file, and the connected library file;

    • Generate debug info
      To generate the debug information to the. PDB file.
      In category-> Debug );
    • Ignore all default Libraries
      , Discard all default database connections;
    • Link incrementally
      , By generating.
      The ilk file implements incremental connections to increase the subsequent connection speed, but the file (exe or DLL) generated in this mode is usually large;
    • Generate mapfile
      Generate information about the. map file record module;
    • Enable profiling
      , This parameter is usually
      The mapfile parameter is used at the same time. If debugging information is generated, the. PDB file cannot be used, and Microsoft format must be used.

    2) customize
    You can set the database file.

    • Force file output
      To generate an output file (exe or DLL );
    • Print progress messages
      , You can output the progress information in the connection process
      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 formats
      Three options;
    • Separate types
      Indicates whether to store the debug format information in an independent. PDB file or directly
      It is stored in the. PDB file of each source file. If selected, the latter method is used. This method is faster for debugging and startup.

    4) Input
    You can specify the database file to be connected and discard the database file to be connected. You can also add additional library file directories, which are usually relative
    Directory of the project, such as ../lib.

    • Force symbol references
      You can specify a library to connect to a specific symbol definition.

    5) Output
     

    • Base Address
      You can change the default base address of the program (the default base address of the EXE file is
      0x400000, DLL defaults to 0x10000000). When the operating system loads a program, it always tries to start from this base address.
    • Entry-point symbol
      You can specify the entry address of the program, which is generally a function name (and required
      Use the _ stdcall call Convention ). Generally, for Win32 programs, the EXE entry is
      In winmain, the DLL entry is dllentrypoint; it is recommended that the connector automatically set the entry point of the program. By default, it is implemented through a C Runtime Library Function: Console
      Use maincrtstartup (or wmaincrtstartup) to call the main
      (Or wmain) function; windows program uses winmaincrtstartup (or
      Wwinmaincrtstartup) calls the winmain (or
      Wwinmain, must use the _ stdcall call Convention); DLL uses _ dllmaincrtstartup to call the dllmain function (must use
      _ Stdcall ).
    • Stack allocations
      Used to set the stack size used by the Program (Please use decimal). The default value is
      1 MB.
    • Version Information
      Tell the connector to release the version at the beginning of the EXE or DLL file
      The current number.

    It is worth noting that:

    1. The above parameters are case sensitive.
      Of;
    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 to connect to the MFC Library (static or dynamic ). For dynamic connection, when the MFC software is released
    Forget the DLL with MFC.

    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.

  • Switch all cl.exe commands

    /C: retained the comment statement in the pre-processing output.
    /C: Compile only, no connection, equivalent to selecting "compile" under the "build" menu"
    /D: defines constants and macros, which have the same effect as # define in the source program.

    /E: Pre-processes the C and C ++ source files, expands all pre-compiled commands and Macros in the source files, removes comments, and copies the output of the pre-processor to the output of the standard output device, and at the beginning of each file and
    Add # Line at the end
    /EH: Specifies the exception handling model used by the compiler.
    /EP: Same as/e, but removed # Line
    /F: Set the stack size of the program.
    /FA: Specifies the list file to be generated (assembly, assembly and machine code, assembly and source code, assembly and machine code, and source code)
    /FA: Specifies the storage path and (or) File Name of the list file set with/FA
    /FD: mutual dependency information of generated files
    /FD: Set the storage path and/or file name of the program database file (PDB)
    /Fe: Set the storage path and/or file name of the final Executable File
    /FI: Pre-processes the specified header file, which has the same effect as # include in the source file.
    /FM: create a map file
    /FO: Set the storage path and (or) File Name of the compiled OBJ file
    /FP: Set the storage path and/or file name of the pre-compiled file (PCH)
    /FR: generate the browsing information (SBR) File
    /FR: Same as/FR. The difference is that/FR does not include local variable information.
    /G3: optimized code generation for the 80386 Processor
    /G4: optimized code generation for the 80486 Processor
    /G5: optimized code generation for the Pentium processor
    /G6: optimized code generation for the Pentium Pro Processor
    /GA: optimizes Windows Applications
    /GB: code generation optimized for the Pentium processor, using 80386, 80486, Pentium, Pentium
    The hybrid Instruction Set of Pro is the default option for code generation (processor corresponds to blend in program attribute options)
    /GD: optimizes Windows dynamic library (DLL). This switch is not implemented in vc6.
    /GD: Specify the function call rules using _ cdecl
    /Ge: Activate stack Detection
    /GF: removes repeated strings in the program and places them in the read-only buffer.
    /GF: removes repeated strings in the program.
    /GH: Call the hook function at the beginning of each function-penter
    /GI: allow progressive Compilation
    /GM: Allows minimal rebuild
    /GR: Run-Time type Infomation)
    /GR: Specify the function call rules using _ fastcall.
    /GS: controls the memory size used for Stack Detection
    /GT: supports Fier-safety for data allocated with _ declspec (thread)
    /GX: Synchronous exception handling is allowed, which is equivalent to/ESCs switch.
    /Gy: allows the compiler to encapsulate each function in the form of comdats for the connector to call.
    /GZ: allows you to capture release build errors during debug build.
    /GZ: Specify the function call rules using _ stdcall.
    /H: restrict the length of external names
    /Help: list all the command Switches of the Compiler
    /I: Specify the search path for the header file
    /J: Change the default char type from signed Char to unsigned char.
    /Ld: create a dynamic Connection Library
    /LDD: create a dynamic link library of the debug version.
    /Link: Pass the specified option to the connector.
    /MD: select the multi-threaded and dll c run-time library.
    /MDD: select the multi-thread, DLL, and debug C run-time libraries.
    /Ml: select the single-threaded C run-time Library
    /MLD: select the single-thread and debug C run-time libraries.
    /MT: select the multi-threaded C run-time Library
    /MTD: select the multi-thread and debug C run-time libraries.
    /Nologo: do not display the copyright information of the program
    /O1: optimize to minimize the number of executable codes generated
    /O2: optimized to produce the fastest executable code
    /OA: indicates that no alias is used in the compiler program, which can increase the execution speed of the program.
    /Ob: controls the expansion of inline functions
    /OD: code optimization prohibited
    /OG: Use global optimization
    /OI: use internal functions to replace function calls in the program, which can make the program run faster, but the program length becomes longer.
    /OP: Improves the consistency of floating point comparison operations
    /OS: Generate as little executable code as possible
    /OT: generate executable code as much as possible.
    /Ow: indicates that the compiler does not use aliases within the function body.
    /Ox: Several optimization switches are combined to achieve as many optimization as possible.
    /Oy: block the creation of frame pointers in the call stack
    /Q1f: generates independent debugging information for core-level device drivers.
    /Qi0f: Correct the Pentium 0x0f error command
    /Qifdiv: Correct the incorrect Pentium fdiv command
    /P: Write the pre-processing output to the specified file. The file suffix is I.
    /TC: compile all the files on the command line as the C source program, regardless of whether the suffix is. c
    /TC: Compile the specified file as a C source program, regardless of whether the suffix is. C.
    /TP: compile all the files on the command line as the C ++ source program, regardless of whether the suffix is. cpp
    /TP: Compile the specified file as a C ++ source program, regardless of whether the suffix is. cpp.
    /U: Remove a specified previously defined symbol or constant.
    /U: Remove all previously defined symbols or constants.
    /V: the version number is embedded in the compiled OBJ file.
    /VD: Disable/allow constructor replacement
    /Vmb: select the pointer representation. Use this toggle to define the class before declaring a pointer to a member of a class.
    /Vmg: select the pointer representation method. With this switch, you do not need to define this class before declaring a pointer to a member of a class, however, you must first specify the Inheritance Method Used for this class.
    /Vmm: Set the pointer to single inheritance and multiple inheritance.
    /VMS: Set the pointer to single inheritance.
    /Vmv: sets the pointer to any class.
    /W: Set the warning level
    /W: Disable all warnings.
    /X: prevents the compiler from searching for standard include directories.
    /YC: Create a pre-compiled header file (PCH)
    /Yd: Write complete debugging information in all OBJ files.
    /YU: Use the specified precompiled header file during the build process.
    /Yx: indicates that the compiler uses the precompiled header file if it exists. If it does not exist, it creates
    /Z7: Generate debugging information compatible with msc7.0
    /Za: Disable Language extension (Microsoft extensions to C)
    /ZD: debugging information only contains the external and global symbol information and line number information
    /Ze: Allow Language extension (Microsoft extensions to C)
    /ZG: generates a function prototype for each function defined in the source file.
    /Zi: Generate library files (PDB) and support edit and continue debugging features
    /Zi: generate a library file (PDB) that contains type information and symbol debugging information
    /ZL: remove the default library file name from the OBJ file
    /ZM: sets the compiler's memory allocation Xianzhi
    /Zn: Disable encapsulation in the information file.
    /ZP: Set the Encapsulation Format of structure members in the memory.
    /Zs: Quick syntax check
    Tips

    1)
    Sometimes, during compilation, your computer suddenly shuts down illegally (maybe someone accidentally hits the power or your memory is unstable ). After you restart the machine, open the project, re-compile and send
    Now VC will collapse. You may think that your VC compiler is broken, but it is not (you should try to compile other projects !), You only need to file the. NCB,. Opt,. APs,. CLW files of the project.
    And delete all the files in the debug and release directories, and 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 files and all files under the debug and release directories.

    3)
    When your workspace contains multiple projects, you may not be able to intuitively see which project is the current one. You can set it as follows: Tools->
    Options-> Format, and then select workspace in category
    Window to 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, delete. CLW and. NCB, re-open the project, and click the menu item View>
    Classwizard, click "add all" in the pop-up dialog box, and rebuild all again. 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.