|
很简单,在 AVR Studio 安装目录的 ./Compilers 子目录里找到 AvrPluginavrgccplugin.dll,然后用随便哪种 hex 编辑器找到字符串 "CC ="(注意空格),把后面跟的 avr-gcc 改成 avr-g++ 即可。
此后所有程序均可使用完整的 C++ 语法(当然,new 和 delete 依然不能用的),例如 inline 函数(减小栈空间消耗)、缺省参数(在类似eeprom写入函数等地方可用来避免程序跑飞导致eeprom被篡改)、局部变量随用随分配(减小栈空间消耗)、类等。
注意:如果是 WinAVR 200601xx 版,转用 C++ 后,在中断服务程序声明那里会遇到警告,这是 avr/interrupt.h 头文件的一点错误,如下修改:
原内容:
#ifdef __cplusplus
#define ISR(vector) \
extern "C" void vector(void); \
void vector (void) __attribute__ ((signal)); \
void vector (void)
修改内容:
#ifdef __cplusplus
/* Bug Fix 20060310
#define ISR(vector) \
extern "C" void vector(void); \
void vector (void) __attribute__ ((signal)); \
void vector (void)
*/
/*Bug Fix 20060310*/
#define ISR(vector) \
extern "C" void vector (void) __attribute__ ((signal)); \
void vector (void)
/*Bug Fix 20060310*/
后面还有两段,依此类推,当然,懒得改的话,直接用 ISR 声明中断服务程序也就是了
-----此内容被avr8529于2006-03-11,08:41:25编辑过 |
|