Use a powerful C/C ++ compiler in Linux

Source: Internet
Author: User

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

 
 
  1. #include   
  2. #include   
  3. int factorial (int n);  
  4. int main (int argc, char **argv)  
  5. {  
  6. int n;  
  7. if (argc < 2) {  
  8. printf ("Usage: %s n ", argv [0]);  
  9. return -1;  
  10. }  
  11. else {  
  12. n = atoi (argv[1]);  
  13. printf ("Factorial of %d is %d. ", n, factorial (n));  
  14. }  
  15. return 0;  
  16. }  

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 ):

 
 
  1. #include   
  2. void main (void)  
  3. {  
  4.  cout << "Hello, world!" << endl;  

You can call the g ++ command to compile, connect, and generate an executable file as follows:

 
 
  1. $ g++ -o hello hello.C   
  2. $ ./hello   
  3. 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.

  1. Differences between standard input implementation methods in C and C ++
  2. How does the C ++ compiler allocate storage space for Const constants?
  3. Basic Conception and method of C ++ Class Library Design
  4. Several Methods for converting C ++ Language
  5. How to better compile C ++ code

Related Article

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.