C language head file declaration

xiaoxiao2021-03-05  24

When we look at other people's source programs, they often see some weird code in the source terminal files. What is the use of these code? For example, this example:

#ifndef __c_log_h__

#define __d_log_h__

#ifdef CPlusplus

Extern "C" {

#ENDIF

TypeDef struct _clog clog;

CLOG * CREATNEWLOG (int Nargnum, ...);

Void * deleteclog (clog * pstrulog);

#ifdef __cplusplus

}

#ENDIF

#ENDIF

Macro definition __c_log_h__ 上 f f _ _ _ _ _ _ 是 _ _ 文件 文件 文件 文件 文件 _ _ _ _ _ _ 则 _ _ _ _ _ _ 则 文件 则 文件 文件 文件 文件 文件 文件 空 空 空 空 空 空 空 空This macro rig, we can repeat this header file in all source code in the future, without having to worry about the repetition definition of some of the information in the header file. Macro definition __cplusplus The #ifdef __cplusplus in the above code is used to determine the current use The compiler is a C compiler or a C compiler. If you use the C compiler, this macro will be automatically defined, otherwise it will not be defined. If we are a C compiler, we have added extern "c" {and back} used to represent Our code is a C language code, which compiled the library compiled by the C compiler We can also use in the C language. Structure Definition The typef struct _clog clog Clog in the CLOG in the CLOG CLOG Clog can hide the internal situation of the structure CLOG. So we can In the source code, the structure of the CLOG is indicated. The various members of this structure cannot be seen in other source code, which is hidden on the structure.

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

New Post(0)