luhuadong / rtt-ssd1306

RT-Thread package for working with OLEDs based on SSD1306, SH1106, SH1107 and SSD1309, supports I2C and SPI. Inspired by stm32-ssd1306.
MIT License
6 stars 5 forks source link

你好,我按照步骤完成后,编译时出现了错误,有一个头文件找不到 #1

Open tianzixiaotanzhong opened 3 years ago

tianzixiaotanzhong commented 3 years ago

packages/ssd1306-latest/inc\ssd1306.h(12): error: '_ansi.h' file not found image 请问这是什么问题呢,我的Keil工程得在RT_Thread的BSP下使用Env工具生成的

luhuadong commented 3 months ago

抱歉,现在才回复!

_ansi.h 是 newlib 提供的头文件,Keil 环境可能没有提供该头文件。引入 _ansi.h 是为了使用 _BEGIN_STD_C_END_STD_C 宏定义,它们的具体定义如下:

/*  ISO C++.  */

#ifdef __cplusplus
#if !(defined(_BEGIN_STD_C) && defined(_END_STD_C))
#ifdef _HAVE_STD_CXX
#define _BEGIN_STD_C namespace std { extern "C" {
#define _END_STD_C  } }
#else
#define _BEGIN_STD_C extern "C" {
#define _END_STD_C  }
#endif
#if __GNUC_PREREQ (3, 3)
#define _NOTHROW __attribute__ ((__nothrow__))
#else
#define _NOTHROW throw()
#endif
#endif
#else
#define _BEGIN_STD_C
#define _END_STD_C
#define _NOTHROW
#endif

如果你的工程是纯 C 的工程,可以直接注释/删除 #include <_ansi.h>_BEGIN_STD_C_END_STD_C 这几行。

如果你的工程是 C 和 C++ 混合的工程,可以先注释/删除 #include <_ansi.h>,再添加如下宏定义:

#define _BEGIN_STD_C extern "C" {
#define _END_STD_C  }