Presentation is loading. Please wait.

Presentation is loading. Please wait.

Compiling a Native C++ Program on the Command Line #define #include.

Similar presentations


Presentation on theme: "Compiling a Native C++ Program on the Command Line #define #include."— Presentation transcript:

1 Compiling a Native C++ Program on the Command Line #define #include

2 Compiling a Native C++ Program on the Command Line Open the Visual Studio 2010 Command Prompt window by clicking Start, pointing to All Programs, Microsoft Visual Studio 2010, Visual Studio Tools, and then clicking Visual Studio 2010 Command Prompt. – Some directories may require administrator credentials to create files. If you prefer to try the following commands with standard users’ privilege, change to a directory which allows you to create/modify files.

3 At the command prompt, type notepad basic.cpp and press Enter. – Click Yes when you are prompted to create a file. In Notepad, type the following lines. #include int main() { std::cout << "This is a native C++ program." << std::endl; return 0; } On the File menu, click Save. At the command prompt, type cl basic.cpp The cl.exe compiler generates an executable program named basic.exe. Type dir basic.* and press Enter. – The.obj file is an intermediate format file that you can safely ignore. To run the basic.exe program, type basic and press Enter.

4 C++ source (basic.cpp) macro expanded C++ source (basic.i) object code (basic.obj) Executable (basic.exe) CL /P CL /c CL Library

5 #define #include using std::cout; #defineAAA5 #defineF(x)printf("The value of " #x " is %d.\n", x) int main() { int a = 1, b = 2; for (int i=0; i<AAA; i++) cout << i << "\n"; F(a); F(b); return 0; }

6 #include CL /P b.cpp CL /c a.cpp a.cpp #include #include "b.cpp" #include "c.cpp" int main() { std::cout << CC << std::endl; return 0; } #define CC 329 b.cppc.cpp


Download ppt "Compiling a Native C++ Program on the Command Line #define #include."

Similar presentations


Ads by Google