2

Can I do like this

/*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_ */

And include this includeAll.h file everywhere. Everywhere means in all the project files.

Similar macro like #define INCLUDEALL_H_ 1 has been used in all the other files.

I see that in compile time it takes very long.

4

2 回答 2

2

除了编译时间损失之外,这样做会使代码的更改/移植/重构变得更加困难。

我有一个一般规则,即我将依赖关系保持在绝对最低限度。在正确的位置包含缺少的标头并不需要太多工作,并且可以为您省去很多麻烦。

于 2011-09-03T09:41:05.237 回答
1

您可以将您的includeAll.h用作预编译标头。我建议将扩展名更改为.pch.

于 2011-09-02T15:50:46.750 回答