【问题标题】:no error for missing c++ function declaration缺少 c++ 函数声明没有错误
【发布时间】:2021-04-07 20:49:36
【问题描述】:

使用 g++,编译以下代码将返回error: ‘test’ was not declared in this scope。但是 Arduino C++ 编译器会 NOT 失败。为什么?我怎样才能让 gcc/g++ 像 Arduino 编译器一样提升函数?

void setup() {
  test();
}

void loop() {}

int test() { return 1; }

长期以来我一直觉得,如果 Javascript、Perl 等可以提升函数,那么 C/C++ 预处理器允许这样做似乎是不合理的。

【问题讨论】:

    标签: g++ hoisting


    【解决方案1】:

    我猜你可能需要一个额外的预处理器。我个人从未尝试过,但也许protoize 对你来说会很有趣!

    【讨论】:

      猜你喜欢
      • 2020-12-07
      • 2014-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-11
      • 1970-01-01
      相关资源
      最近更新 更多