C language to create a header file

How to customize the header file under the C project created by yourself?

#ifndef A_ADD_B       //先测试A_ADD_B是否被宏定义过
#define A_ADD_B
   method_A(int, int) //如果A_ADD_B没有被宏定义过,则定义A_ADD_B,编译执行method_A(int, int)
#endif   
  method_B(int, int) //如果A_ADD_B已经定义过了,则编译执行method_B(int, int),“忽视”程序段 1

可以单独在一个.c文件里面实现method_A(int, int)、method_B(int, int)具体函数实现,也可以在宏定义下面(method_A方法处)直接实现

条件指示符#ifndef 的最主要目的是防止头文件的重复包含和编译.

 

 

Guess you like

Origin blog.csdn.net/qq_52686989/article/details/130614353