How C/C ++ compiler works

Source: Internet
Author: User

The C/C ++ compiler works by translating the source code to the target code that can be directly executed by a computer or virtual machine. However, the C/C ++ compiler is one of the earliest compilers, now let's study and research it. I hope you can get what you want.

In the GCC family, gnu gcc is fundamental, and other compiler versions are exported from it. Among them, Cygwin and Mingw32 are both compilers on the WIN32 platform, while DJGPP is a 32-bit compiler under DOS. The well-known DEV-C ++ is at best a shell of GCC, and its built-in compiler is a version of Mingw32.

Among these GCC versions, Cygwin is the largest. It is not so much a compiler as a programming tool. It not only has compilers, but also has many other tools. In fact, it is the implementation of a UNIX System on the WIN32 platform. Most commonly used UNIX tools are implemented. In recent versions, "Tools" such as Apache are integrated.

However, although Cygwin is powerful, it is not very easy to use and UNIX is similar, people familiar with UNIX can use it quickly), because too many other tools distract people's attention. Compared with Mingw32, Mingw32 is much easier to use. It has only a few basic programming tools, but it does not come with GDB ).

GCC is not only a C/C ++ compiler, but also many other compilers such as JAVA, Fortran, and ADA. It is a set of compilers, but some compilers can only be used on UNIX systems. The compiler of the MS family is not required. Everyone is familiar with them. VC 7.0 (VC. NET) is its latest product. Needless to say, the Borland family is also familiar to everyone. Recently, it launched BCB 6.0.

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. The C/C ++ compiler was a member of the previous four-nation battle of compilers. 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 something IBM wanted to use for the C ++ compiler, but IBM's strategy was changed and it was abandoned. Symantec C ++, the predecessor of DigitalMars C/C ++, is also a member of the four major compiler wars, 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 an open-source compiler, which is very simple and used to learn 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.

  • How to overload C ++ Functions
  • Notes for handling C ++ static members
  • How to construct C ++ virtual base class Constructor
  • Easily solve C ++ exceptions
  • Summarize stack objects referenced in C ++/CLI

Of course, there are many other compilers. Here the compilers I provide can be used on WIN32 or DOS platforms except for KAI ). The compilers on UNIX platforms are mainly GNU, and I am not very clear about the others. Among the above compilers, the most special thing is that VectorC only supports pure C.

However, it is called the fastest compiler, but after my experiments, it is indeed more powerful than other compilers in some cases! It also has an interactive optimizer that allows you to directly view the assembly code mapped to the C code. Cygwin and Mingw32 are born to a mother, and their running effect is not much different. The code they generate is very efficient and the compilation speed is very fast. The most important thing to note is that their support for C ++ features is the most complete of all compilers, they also support most of the C99 features.

This is very good! You are familiar with ms vc. However, it has made great improvements in its latest product VC7.0. Its support for C ++ features is greatly improved than 6.0, which is second only to GCC in the compiler I use. And the program compiled by it runs fast! There are only a few cases where javasvectorc and GCC are the fastest! The average running speed is the fastest. I don't need to talk about Borland products. Both TC2.0 and BC3.1 are my favorite things.

However, BCB is not as slow as VC6! IDE also has many bugs. The most puzzling thing is that the Code it generates runs slowly, slower than the LCC-WIN32! The only thing that is worth mentioning is that RAD does better than MS. Intel compilers may be unfamiliar. It's too expensive!

It is not cost-effective to support VC, and the compilation speed is slower than that of VC6. However, its code quality is very good. DigitalMars C/C ++ has no highlights. It has a fast Compilation speed, moderate code execution speed, and good support for the C ++ feature. LCC-WIN32 is a very good integrated development environment, it only supports pure C.

It Compilation speed is extremely fast! The code execution speed is slow. But its biggest highlight is its IDE. Among all the FREE programming tools, its IDE is the most professional and has powerful code analysis and management functions. It also provides a lot of programming materials.

I have tested the code execution efficiency of some C/C ++ compilers. The following is an overview:
1. VectorC, VC 7.0 extremely fast)
2. Intel C/C ++, VC 6.0, and GCC soon)
3. DigitalMars C/C ++ General)
4. LCC-WIN32, BCB, BC5.02 (slow)
Of course, my tests are one-sided. However, the general situation has been largely reflected.

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.