Benefits of-e parameters on GCC

Source: Internet
Author: User

There are many GCC parameters. Here is a very important parameter-e.

If we just want to pre-process the source file,-E will be useful.

 

What can it do?

(1) Expand All predefined # define defined by the user.

For example, if you have the following code:

# Define max (A, B) (a)> (B )? (A) (B ))

...

Int c = max (A, B );

After GCC preprocessing, the pre-definition will be expanded as follows:

Int c = (a)> (B )? (A) (B ));

 

(2) load all the # include files.

If we have # include <stdio. h>, after preprocessing, the program will replace it with the content of stdio. h # include <stdio. h>,

In the final program, you will not be able to find such include, more of which are # include "/usr/include/stdio. H.

With this, you can know a) stdio. h storage path in Linux, B) file structure samples, c) size_t type definition, d) many other things you want to know

 

(3) process Conditional compilation and delete code segments that do not meet the criteria.

For example, there is a code segment:

# Ifdef m

Printf ("M ");

# Else

Printf ("Nm ");

# Endif

After preprocessing, the program will become

 

Printf ("M ");

 

 

(Because no # define m is available and other rows are left blank, the Code printf ("Nm") will be deleted)

 

How to use it?

Easy to use: gcc-e a. C.

If you want to save the result, redirect it to a file, such as gcc-e. c> B. c. c Compilation: gcc-o B. c. The running effect is the same as that of. c)

 

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.