库配置不支持 IAR 中的 I/O

问题描述

我是 IAR 的新手,我只是在配置一个 C++ 项目,但我对这个错误感到惊讶: Fatal error[Pe035]: #error directive: "This library configuration does not support file I/O,either use another existing library configuration or define a new and rebuild the library." 在 fstream 文件中(在我的情况下为只读)。

以下是导致错误代码行:

#if !_DLIB_FILE_DESCRIPTOR
  #error "This library configuration does not support file I/O,either use \
          another existing library configuration or define a new and rebuild \
          the library."
#endif

我该如何解决这个问题?

解决方法

默认情况下不启用文件流。

转到您的项目选项(Project > Options... 菜单),选择 General Options 类别和 Library Configuration 选项卡。从 Library 下拉列表中选择 Full

请注意,这只是启用库中的文件流。当您将文件流与 C-SPY 调试器(我认为启用了半主机)一起使用时,它会在您的计算机上打开文件。为了从嵌入式设备内存中读取文件,您还需要实现 DLIB 低级 I/O 接口。阅读 IAR 手册了解如何做到这一点。