我可以这样做吗
/*includeAll.h*/
#ifndef INCLUDEALL_H_
#define INCLUDEALL_H_ 1
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include "DataTypeDefs.h"
#include "timer_api.h"
#include "uart_api.h"
#include "RTC_PCF8563.h"
#include "TWI_Master.h"
#include "ADC_LTC1859.h"
#include "spi.h"
#include "AT45DB161D_UART_AS_mSPI.h"
#include "Utilities.h"
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#include <util/delay.h>
#include <string.h>
#endif /* INCLUDEALL_H_ */
并在各处包含此 includeAll.h 文件。 无处不在意味着在所有项目文件中。
类似的宏如 #define INCLUDEALL_H_1 已在所有其他文件中使用。
我发现编译时间需要很长。
最佳答案
除了编译时间损失之外,这样做还会使代码的更改/移植/重构变得更加困难。
我有一个一般规则,就是将依赖关系保持在绝对最低限度。将丢失的 header 包含在正确的位置并不需要太多工作,并且可以在以后为您省去很多麻烦。
关于c - 将所有文件包含在一个 .h 文件中并在 AVR 的任何位置都包含该文件是否是一种好习惯?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7285476/