During the compilation process, we found that the C ++ compiler is a very powerful C/C ++ compiler, which features high speed and high space efficiency, its version supports up to 92.73% Standard C ++ and greatly supports CPU optimization.
If you have two or a few C source files, you can easily use GCC to compile, connect, and generate executable files. For example, if you have two source files main. c and factorial. c, compile a program to calculate factorial.
Listing main. c
- #include
- #include
- int factorial (int n);
- int main (int argc, char **argv)
- {
- int n;
- if (argc < 2) {
- printf ("Usage: %s n ", argv [0]);
- return -1;
- }
- else {
- n = atoi (argv[1]);
- printf ("Factorial of %d is %d. ", n, factorial (n));
- }
- return 0;
- }
GCC can be used to compile both C and C ++ programs. Generally, the C compiler uses the extension of the source file to determine whether it is a C program or a C ++ program. In linux, the extension of the C source file is. c, and the extension of the C ++ source file is. C or. cpp.
However, the gcc command can only compile the C ++ source file, but cannot automatically connect to the library used by the C ++ program. Therefore, the g ++ command is usually used to compile and connect the C ++ program. The program automatically calls gcc for compilation. Suppose we have the following C ++ source file hello. C ):
- #include
- void main (void)
- {
- cout << "Hello, world!" << endl;
- }
You can call the g ++ command to compile, connect, and generate an executable file as follows:
- $ g++ -o hello hello.C
- $ ./hello
- Hello, world!
Other compilers, such as Intel C/C ++, are known to be Intel at first glance. It is fully compatible with VC6, but can only be used when it is attached to VC6. Watcom C/C ++ was a member of the four-nation compiler war earlier. It was a good thing. Unfortunately, the strategy is wrong, and now it's gone. An OpenWatcom based on it is still fighting.
VectorC is a good stuff that I recently discovered. It is a pure C compiler. IBM's VisualAge for C ++ was originally intended for the powerful C/C ++ compiler, but it was abandoned after IBM's strategy was changed. Symantec C ++, the predecessor of DigitalMars C/C ++, is also a member of the four-nation compiler war), but Symantec does not do it now.
So the author changed it to DigitalMars C/C ++ for use. All of the above are on the WIN32 platform. Kai c/C ++ is a powerful C/C ++ compiler with multiple platforms. However, it has been acquired by INTEL and has stopped development. Lcc4.1 is a pure C compiler. It is open source code.
But it is not easy to use. LCC-WIN32 is a C language on the basis of the development of the C language integrated development environment, very easy to use, and there are very detailed information, FREE! Pacific C is an integrated development environment for pure dos c. Small C CC386 is a powerful open-source C/C ++ compiler, which is very simple. The application is used to learn the compiler. Quincy Eic CINT is a C interpreter. It is used to help you learn about C language. CINT is powerful and supports some C ++ features.
- Differences between standard input implementation methods in C and C ++
- How does the C ++ compiler allocate storage space for Const constants?
- Basic Conception and method of C ++ Class Library Design
- Several Methods for converting C ++ Language
- How to better compile C ++ code