设为首页 加入收藏

TOP

1.1 Writing a Simple C++ Program (3)
2013-10-07 16:13:48 来源: 作者: 【 】 浏览:73
Tags:1.1 Writing Simple Program

RUNNING THE GNU OR MICROSOFT COMPILERS

The command used to run the C++(www.cppentry.com) compiler varies across compilers and operating systems. Themost common compilers are the GNU compiler and the MicrosoftVisual Studio compilers. By default, the command to run the GNU compiler is g++:

  1. $ g++ -o prog1 prog1.cc  

Here $ is the systemprompt. The -o prog1 is an argument to the compiler and names the file in which to put the executable file. This command generates an executable file named prog1 or prog1.exe, depending on the operating system. On UNIX, executable files have no suffix; on Windows, the suffix is .exe. If the -o prog1 is omitted, the compiler generates an executable named a.out on UNIX systems and a.exe on Windows. (Note: Depending on the release of the GNU compiler you are using, you may need to specify -std=c++0x to turn on C++(www.cppentry.com) 11 support.)

The command to run theMicrosoft Visual Studio 2010 compiler is cl:

C:\Users\me\Programs> cl /EHsc prog1.cpp

Here C:\Users\me\Programs> is the system prompt and \Users\me\

  1. C:\Users\me\Programs> cl /EHsc prog1.cpp  

Programs is the name of the current directory (aka the current folder). The cl command invokes the compiler, and /EHsc is the compiler option that turns on standard exception handling. TheMicrosoft compiler automatically generates an executable with a name that corresponds to the first source file name. The executable has the suffix .exe and the same name as the source file name. In this case, the executable is named prog1.exe.

Compilers usually include options to generate warnings about problematic constructs. It is usually a good idea to use these options. Our preference is to use -Wall with the GNU compiler, and to use /W4 with the Microsoft compilers.

For further information consult your compiler’s user’s guide.

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇1.1 Writing a Simple C++ Progra.. 下一篇1.2 A First Look at Input/Outpu..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·数据库:推荐几款 Re (2025-12-25 12:17:11)
·如何最简单、通俗地 (2025-12-25 12:17:09)
·什么是Redis?为什么 (2025-12-25 12:17:06)
·对于一个想入坑Linux (2025-12-25 11:49:07)
·Linux 怎么读? (2025-12-25 11:49:04)