【问题标题】:Arduino MIDI controller menuUsed was not declared in this scopeArduino MIDI 控制器 menuUsed 未在此范围内声明
【发布时间】:2016-04-15 08:44:11
【问题描述】:

尝试构建一个 MIDI 功能区控制器,发现有人已经编写了所有必要的代码,但是当我尝试将其上传到 arduino 时,我收到以下错误:

sketch_apr13a:122: error: 'menuUsed' was not declared in this scope
MenuBackend menu = MenuBackend(menuUsed,menuChanged);
                                ^
sketch_apr13a:122: error: 'menuChanged' was not declared in this scope
MenuBackend menu = MenuBackend(menuUsed,menuChanged);
                                  ^
exit status 1
'menuUsed' was not declared in this scope

由于我不太擅长整个编码,所以我有点难过,现在只能抓住稻草。

完整的代码可以在这里找到:http://www.coagula.org/content/sites/default/files/source/MIDI_Ribbon_Controller_2.pde

问题出在第 122 行,可能是第 609 和 506 行(因为那里有函数)

【问题讨论】:

    标签: c arduino


    【解决方案1】:

    函数menuUsed是在你尝试使用后定义的,所以编译器还不知道名字。

    您可以做的是在使用之前声明名称,使用 static 关键字。

    static void menuUsed(MenuUseEvent used);
    

    当然与 menuChanged 相同。

    static void menuChanged(MenuChangeEvent changed);
    

    如果 MenuUsedEvent 和 MenuChangedEvent 不在某个标题中,您可能仍会遇到编译器错误。

    【讨论】:

    • 谢谢,做到了,但现在我只需要弄清楚如何让它在更新的 Arduino 上工作,因为事情会在 5 年内发生变化(谁会想到它)。
    猜你喜欢
    • 1970-01-01
    • 2016-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多