answersLogoWhite

0


Best Answer

C++ programs consist of one or more translation units that must be compiled and linked to create an executable. Each translation unit is compiled separately to produce an object file. When all translation units are compiled, the object files are linked.

Translation units must be preprocessed before they can be compiled. That is, all macros must be expanded (replacing macro tokens with their expanded definitions) and all required include files are pulled in. The end result is an intermediate file which is the actual file processed by the compiler. During preprocessing of a translation unit, the include files for that unit are also preprocessed and expanded as necessary.

Not all translation units need to be compiled in every compilation. If a modification to the program has no effect upon a translation unit, the object file generated by a prior compilation can be used instead. This helps speed up the compilation process.

Headers that require little or no maintenance (such as standard library headers) can also be precompiled to help speed up the process even further.

Header files are often included in several translation units but can only be included once per compilation. To avoid unnecessary inclusions, headers typically use special macros known as inclusion guards of the following form:

// file: my_header.h

#ifndef _MY_HEADER_H_

#define _MY_HEADER_H_

// content goes here

#endif _MY_HEADER_H_

Inclusion guards typically use the file name as the basis for the macro definition and are deliberately ugly to avoid name clashes with other macros. The first time the header is processed, the macro will be undefined thus the content can be pulled into the intermediate file. All subsequent inclusions will see that the macro is already defined and will ignore the content.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

This is typically handled by your IDE's build command, which not only compiles your program but links it in a single step. In Microsoft Visual Studio, for instance, you compile and link with the F7 function key (or select Build > Build Solution from the menu bar). To examine the command line equivalents, open the project properties (ALT+F7) and examine the C/C++ > Command Line and the Linker > Command Line pages.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

Use your compiler's IDE and look for an option to build your executable. The verb "build" is commonly used to indicate your program will be both compiled and linked to produce an executable.

To do the same thing from the command line, you need to determine the command that invokes the compiler. E.g., in VC++, the command is cl.exe but in GCC it is gcc.exe. Consult your compiler's documentation for the correct syntax.

This answer is:
User Avatar

User Avatar

Wiki User

7y ago

No. By definition, a C++ program is a program that can only be compiled by the C++ compiler. Although the two languages do have much in common, not all C programs are valid in C++ but no C++ program can ever be valid in C. That is, if a C++ program can be compiled by a C compiler then it was never a C++ program to begin with; it was just a C program.

This answer is:
User Avatar

User Avatar

Wiki User

7y ago

No. C compilers can only compile C programs. However, Most C++ compilers can compile both C and C++ programming languages. Some IDE prefer to use C++ compiler in compiling both languages to conserve space and to implement ease of use for all of the users.

A great example for this is GCC. GNU Compiler Collection's 'gcc.exe' can only compile C programs. If you want to compile a C++ program, you must call 'g++.exe' instead of 'gcc.exe'. You can still compile C programs using 'g++.exe'.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

No, only compiler, there's no C++-interpreter

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you compile the program in c plus plus program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can visual basic compile a c plus plus program?

As much as your car can fly.


How do you convert from assembly to binary in c plus plus?

Use inline assembly instructions. Then compile your C++ program to produce the machine code.


Does C plus plus compiler will compile C in programming?

Yes we can compile a c program using c++ compiler. Because c++ evolved from the c. c++ have some additional features beyond c. c++ support almost all concepts used in c.


Is C plus plus preprocessor software?

Sometimes, it is. Some implementations compile C++ code into C code, and then compile the C code.


How a c program execute?

Compile and link it into an executable.


How do you use c program?

Compile, link and execute them.


How is C program portable?

Your program is portable if you can compile and execute it on different platforms.


What are the steps in c plus plus?

Code, compile, link, run.


How do you compile a c program in windows OS?

First, install a C-compiler.


What is the difference between make and compile in c?

make is a utility program, compile means translation from source to object module.


How is a C program rum?

C-source program doesn't rum, you have to compile and link it. The executable rums like any other binary program.


CAn you work in c or c plus plus without editor?

You can compile, link and execute programs without text-editor.