为什么不在头文件做定义

Reference:
为何不能在头文件里写定义?

// a.c文件
#include "c.h"
// #include "c.h"

int main(void)
{
	
	return 0;
}
// b.c文件
#include "c.h"
// #include "c.h"
// c.h文件
/*
#ifndef _C_H_
#define _C_H_
*/
#define ONE 1

int i = 1;

void print_no_hello(void)
{
	
}

typedef enum t_level // 加#ifndef _C_H_的原因是数据类型的定义不能在同一个.c文件内重复
{
	LEVEL_LOW,
	LEVEL_HIGH,
}T_LEVEL;

typedef unsigned char uint8_t;

void print_no_hello(void);

/*
#endif
*/
posted @ 2024-08-18 01:39  stitchCat  阅读(15)  评论(0)    收藏  举报