0

我正在尝试编译一些最初使用 GCC 为 SDCC 编写的 c 代码,以便在主机上运行一些单元测试。SDCC 有一些语言扩展,例如__xdataor __pdata(用于内存控制),它们应该保留给 SDCC,但在使用 GCC 编译时应该被忽略。我强烈不希望修改被测模块。有没有办法做到这一点?

我已经发现如果我#define __xdata在被测模块中添加类似的东西,它会起作用。因此,也许有可能有类似“全局定义”的东西?我对 GCC 的经验很少。也许有编译器标志可以帮助我?

4

1 回答 1

0

There are two compiler flags, you could use:

  • -include allows you to give a c file that is additionally included and do the defines in that file.
  • Define macros via command line options -D__xdata=
于 2021-05-06T03:16:58.717 回答