【发布时间】:2020-02-27 05:45:49
【问题描述】:
我目前正在将一个大型项目从 ICCAVR 移植到 Atmel Studio,因为我需要为我正在处理的项目使用一些 ASF 库。
下面的代码示例在尝试将以下行转换为 Atmel Studio 时遇到此错误
void debugoutf(__flash char * header, __flash char * msg);
指向地址空间“__flash”的错误指针必须是 const in 函数参数'header'
我尝试使用文档中的宏,以便它可以在 Atmel Studio 中编译。
#ifndef FLASHVAR_H_
#define FLASHVAR_H_
#include <avr/pgmspace.h>
#if defined(__ICCAVR__) // IAR C Compiler
#define FLASH_DECLARE(x) __flash x
#endif
#if defined(__GNUC__) // GNU Compiler
#define FLASH_DECLARE(x) x __attribute__((__progmem__))
#endif
IAR 到 AVR 的转换
void debugout(FLASH_DECLARE (char * header), char * msg);
我的问题是我是否正确完成了转换,因为我认为我没有正确完成转换,因为在我的 UART 调试中没有打印任何内容。
【问题讨论】:
-
您是否尝试按照错误提示执行操作?即:
#define FLASH_DECLARE(x) const (x) __attribute__((__progmem__)) -
我使用了问题中所示的宏
-
...当你添加 const 时会发生什么?
标签: embedded atmega atmel iar atmelstudio