The #ifndef of C tips

Source: Internet
Author: User

  The #ifndef in the header file, this is a very key thing. For example, you have two C files, and these two C files include the same header file. At compile time, these two C files are compiled into a running file together, so the problem comes with a lot of conflicting statements. or the contents of the head file in #ifndef and #endif. Regardless of whether your header file will be referenced by multiple files, you should add this. The general format is this:

1 #ifndef < identification >2#define < identity >3456  7#endif

  < identity > can theoretically be freely named, but the "identity" of each header file should be unique. The naming convention for an identity is usually the header file name all uppercase, underlined, and the "." in the file name. Also becomes underlined, such as: stdio.h

1 #ifndef _stdio_h_ 2 #define _stdio_h_34 ... 5 6 #endif

The #ifndef of C tips

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.