Perform CL and EditPlus to the end

Source: Internet
Author: User
/G3 is 80386 optimized
/GH enable _ exit function call
/G4 is 80486 optimized
/GR [-] Enable C ++ RTTI
/G5 for Pentium Optimization
/GX [-] Enable C ++ EH (same as/ESCS)
/G6 PPro, P-II, P-III optimized
/Enable C ++ EH for EHs (no SEH exception)
/GB for Mixed Model Optimization
/EHa enables C ++ EH (w/SEH exception)
/Gd _ cdecl call reduction
/EHc external "C" Default Value: nothrow
/Gr _ fastcall call reduction
/GT generate fiber Security TLS code
/Gz _ stdcall call reduction
/Gm [-] Enable minimum regenerate
/GA optimizes windows Applications
/GL [-] Start link generation
/Gf enable character pool
/Qlfdiv [-] Enable Pentium FDIV repair
/GF Enable Read-Only character pool
/QlOf [-] Enable Pentium 0x0f repair
/Gy separates the linker Functions
/Qlfist [-] Use FIST instead of ftol ()
/GZ Enable stack check (/RTCs)
/RTC1 enable quick check (/RTCsu)
/Ge enforces stack check for all functions
/RTCc conversion to small type check
/Gs [num] Control Stack check call
/RTCs stack frame runtime check
/GS enable security check
/Check the local usage of RTCu not initialized
/Gh enable _ penter function call
/Clr [: noAssembly]: Library compilation noAssembly when the common language runtime-No assembly is generated

(From: http://jjhou.csdn.net/article99-10.htm)
I always encourage C/C ++ learners to first target the console mode (DOS-like) program when they are new to this programming language. In other words, you don't want to write GUI programs, open windows, and have a dazzling screen at the beginning-it's just not going to fly first.

The so-called console program is a program in the text mode. We can train the C/C ++ language well without being distracted by other unnecessary guis.

I always thought that this was a matter of course, but I still found that many colleges and universities have freshman C/C ++ courses, students must write a small writer, painter, and Abacus as their mid-term or final assignments.

Sure enough, the world cannot be the same.

I not only think that C/C ++ Program Development objects should be dominated by console mode at the initial stage, but I also think that the C/C ++ program development environment should also be dominated by console mode at the initial stage. In other words, do not start with the integrated environment (IDE ). The integration of so many windows, so many functions, and so many preset values in the environment will make new programmers confused and fail to master some valuable knowledge and experience during program compilation.

When we have a minimum understanding of the Compilation Program, and then use the integrated environment, I think this is the best.

Therefore, no matter in <simple introduction to MFC> or <multi-type and virtual> books, I will briefly describe the job methods in console mode. <Simple introduction to MFC> listed in p.m. and <multi-type and virtual> listed in p.233.

However, I still occasionally receive questions from netizens (whether or not I have read two books), asking about how to compile the console mode, or asking them about the problems they encountered.

I will sort out this question again. Then, I can mail the whole question to the questioner.

★★Note: The following are suitable for PC environments:★★

● Environment variable settings required by the C/C ++ Compiler

In the early days, the C compiler on PC requires two environment variables:

LIB: This environment variable tells the compiler where libraries is necessary (under which disk directory)
INCLUDE: Tell the compiler where the necessary header files are (under which disk directory)

In addition, in order for us to get the compiler in any working directory, we must set the PATH.

From the beginning to the present, C/C ++ compilers all need these three environment variables.

● Take Visual C ++ as an Example

Take Visual C ++ as an example. If the file layout after installation is as follows:

C: \ MSDEV \ VC98 \ BIN: the compiler CL. EXE is provided here.
C: \ MSDEV \ VC98 \ INCLUDE: C/C ++ header files
C: \ MSDEV \ VC98 \ LIB: C/C ++ standard libraries

You can write a batch file as follows:

Set PATH = C: \ MSDEV \ VC98 \ BIN; C: \ MSDEV \ COMMON \ MSDEV98 \ BIN
Set INCLUDE = C: \ MSDEV \ VC98 \ INCLUDE
Set LIB = C: \ MSDEV \ VC98 \ LIB

The reason for setting PATH = C: \ MSDEV \ COMMON \ MSDEV98 \ BIN is that the compiler CL. MSPDB60.DLL is required for EXE execution, and it is installed in C: \ MSDEV \ COMMON \ MSDEV98 \ BIN.

If the program you write is not just a C/C ++ program, but also an MFC program, you can compile it in console mode. At this time, your environment variables should be set as follows:

Set PATH = C: \ MSDEV \ VC98 \ BIN; C: \ MSDEV \ COMMON \ MSDEV98 \ BIN
Set INCLUDE = C: \ MSDEV \ VC98 \ INCLUDE; C: \ MSDEV \ VC98 \ MFC \ INCLUDE
Set LIB = C: \ MSDEV \ VC98 \ LIB; C: \ MSDEV \ VC98 \ MFC \ LIB

If you specify MFC \ INCLUDE and MFC \ LIB, the compiler and the connector can find the MFC header files and libraries. If you still need to Use ATL, you must add C: \ MSDEV \ VC98 \ ATL \ INCLUDE to the INCLUDE environment variable.

● Taking Borland C ++ Builder as an Example

Taking Borland C ++ Builder as an example, if the file layout after installation is as follows:

C: \ BORLAND \ CBuilder3 \ BIN: the compiler BCC32.EXE is provided here.
C: \ BORLAND \ CBuilder3 \ INCLUDE: C/C ++ header files
C: \ BORLAND \ CBuilder3 \ LIB: C/C ++ standard libraries

You can write a batch file as follows:

Set PATH = C: \ BORLAND \ CBuilder3 \ BIN
Set INCLUDE = C: \ BORLAND \ CBuilder3 \ INCLUDE
Set LIB = C: \ BORLAND \ CBuilder3 \ LIB

● How to compile C/C ++ programs in the console

First, enable a DOS Box (DOS Prompt, dos vm), and then execute the preceding batch files in the DOS box to complete environment variable settings. You can enter the set command in the DOS prompt to check whether the environment variable settings are correct.

Then you can directly enter the name of the compiler under the DOS prompt to start compilation. If you use Visual C ++, do this:

C: \> CL test. cpp <Enter>

If you use C ++ Builder, do this:

C: \> BCC32 test. cpp <Enter>

In special cases, you must check the special options. Just execute CL /? Or BCC32 (without any reference), you can see all the compile options.

● Relationship between the compiler and the connector

The early compilation process is separated from the join process. In other words, we must do two actions:

C: \> Cl test. cpp
C: \> LINK test. obj xxx (xxx represents all necessary libraries)

Or:

C: \> BCC32 test. cpp
C: \> TLINK32 test. obj xxx (xxx represents all necessary libraries)

Today's compilation process and linking process are of course separate, but we only need one action:

C: \> CL test. cpp

Or:

C: \> BCC32 test. cpp

This is because the compiler becomes smarter. Unless you specify/c option (indicating that only compilation is not associated), it automatically calls the connector for you. The question about which libraries to use has plagued programmer in the past. The Compiler also has a smart solution: it records the library functions used in the program, the name of the library to which they belong is also recorded, so that the connector can know which libraries to be joined from this table.

● Relationship between environment variables and dos vm (Virtual Machine)

You can enable multiple DOS boxes at the same time, but you cannot execute the above batches in a DOS Box and enjoy the environment settings in another dos vm.

This is because every DOS Box is a Virtual Machine, and no one can see each other.

Unless you have set these environment variables in autoexec. bat. In this case, any newly opened dos vm inherits the original dos vm environment and inherits the variable settings.

● Insufficient environment space

One of the most common problems is the lack of environment space.

After Visual C ++ is installed, a file named VCVARS32.BAT is found in its BIN subdirectory. This file is actually used to set the environment variables (this is described in the last step of the Visual C ++ installation process. Ah, don't read the instructions for installing software for many people !). Therefore, you can execute this file in any DOS Box to replace our own batch file.

However, we usually have experiences of failures"Out of environment space"Error message. This is because VCVARS32.BAT uses the following syntax:

Set INCLUDE = % MSVCDir % \ ATL \ INCLUDE; % MSVCDir % \ MFC \ INCLUDE; % INCLUDE %
Set LIB = % MSVCDir % \ LIB; % MSVCDir % \ MFC \ LIB; % LIB %

This means that the original INCLUDE settings (% INCLUDE %) are appended with other settings, and the original LIB settings (% LIB %) are appended with other settings. If the original setting has been very long, so many times, "Out of environment space!

One way is to increase the size of the Environment Space. Please add this line in the c: \ config. sys file:

Shell = C: \ COMMAND. com c: \/E: 1024/P

/E: 1024 indicates that the environment space is adjusted to 1024 bytes. (Not enough? Re-tune)

The second practice is not to use the "additional" pattern of VCVARS32.BAT. Instead, use our own batch file. You know, we may have several compiler environments (VC, BCB, G ++ compiler), and we need to test our program in turn. If we use the "additional" sentence pattern, we will try it several times, even a large environment space will be exhausted.

Both method 1 and method 2 must be implemented.

● Is there any scale limit?

Can I use the console mode (or command line mode) to compile a program? Is there any size limit on the program size? The answer is no!

Its disadvantage is that there is no tool to help you manage your files, there is no preset value for you to play a few words less, there is no analysis tool to help you organize objects, let you browse objects, symbols volumes. So once you have learned the basic skills, it is better to start designing medium and large programs by integrating the environment (IDE.

● Do not misunderstand

I am not reversing the game. I want everyone to go back to the age of Ru Mao drinking blood and be the best man. I think that for a C/C ++ beginner, the use of integrated environment (IDE) may be confusing. It is better to first work in console mode. On the one hand, I have a good understanding of some common environment settings. On the one hand, it is more convenient and easy to use, and I don't have to write a 1000-line small exercise. I have to start the native cannon, on the one hand, the power of knowledge can all be put on Language exercises.

If the integrated environment is used to a certain extent, it will not fall into the fog.

EditPlus usage tips:
Http://www.crsky.com/article/article_1_1.html

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.