7, #ifndef in header files

xiaoxiao2021-03-06  84

------------

Don't ignore the #ifndef in the first part, this is a very critical thing. For example, you have two C files, both C files include the same header file. When compiling, these two C files should be compiled into a run file, so there is a problem, a large number of statements conflicts.

Still put the contents of the header files in #1ndef and #ndif. Whether your header will be referenced by multiple files, you have to add this. The general format is like this:

#ifndef

#define <标>>

......

......

#ENDIF

In theory, it can be freely named, but this "identification" of each header file should be unique. Named rules identified are generally the header file name, and the line is added to the file, and "" in the file name "also becomes underline, such as: stdio.h

#ifndef _STDIO_H_

#define _STDIO_H_

......

#ENDIF

(BTW: More useful features for pre-compilation. Do you use precompiled?)

转载请注明原文地址:https://www.9cbs.com/read-107745.html

New Post(0)