Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/126.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在c+;中导致非常量绑定错误的Arduino代码+;为了库里布尔_C++_Xcode_Arduino_Bluetooth Lowenergy_Intel - Fatal编程技术网

C++ 在c+;中导致非常量绑定错误的Arduino代码+;为了库里布尔

C++ 在c+;中导致非常量绑定错误的Arduino代码+;为了库里布尔,c++,xcode,arduino,bluetooth-lowenergy,intel,C++,Xcode,Arduino,Bluetooth Lowenergy,Intel,为了使用xcode作为IDE,我尝试将BLE示例代码从.ino移植到.cpp。我习惯于在ino和cpp语言之间进行细微的更改,但由于一个错误而措手不及,如下所示。我正在使用core-libs101库的主分支,我已经将它链接到我的xcode cpp项目 在示例草图中,以下步骤起作用: (此处提供:) 然而,当我在.cpp中尝试相同的操作时,我得到了一个“对类型'BLECharacteristic'的非常量左值引用无法绑定到不相关类型'BLECharacteristic'的值”编译错误。当我将BLE

为了使用xcode作为IDE,我尝试将BLE示例代码从.ino移植到.cpp。我习惯于在ino和cpp语言之间进行细微的更改,但由于一个错误而措手不及,如下所示。我正在使用core-libs101库的主分支,我已经将它链接到我的xcode cpp项目

在示例草图中,以下步骤起作用: (此处提供:)

然而,当我在.cpp中尝试相同的操作时,我得到了一个“对类型'BLECharacteristic'的非常量左值引用无法绑定到不相关类型'BLECharacteristic'的值”编译错误。当我将BLECharCharacteristic的类型更改为BLECharacteristic,并保持其他所有内容不变时,不会出现编译错误

例如: //.cpp代码

#include "CurieBLE.h"

BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214");
BLECharCharacteristic myFailedChar("19B10001-E8F2-537E-4F6C-D104768A1214");
BLECharacteristic myWorkingChar("19B10002-E8F2-537E-4F6C-D104768A1214");

int main(int argc, const char * argv[]) {

    //throws compile error: non-const lvalue reference to type 'BLECharacteristic' cannot bind to a value of unrelated type 'BLECharacteristic'
    ledService.addCharacteristic(myFailedChar);

    //Does not throw compile error.
    ledService.addCharacteristic(myWorkingChar);

    return 0
}

在嵌入式C中,我比嵌入式C++更舒服,所以这可能是一个业余错误,但我无法左右它。任何帮助都将不胜感激

> Pr>实例是为ARDUIO编写的,C++代码与ARDUIO环境高度耦合,不必费力地尝试端口。
#include "CurieBLE.h"

BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214");
BLECharCharacteristic myFailedChar("19B10001-E8F2-537E-4F6C-D104768A1214");
BLECharacteristic myWorkingChar("19B10002-E8F2-537E-4F6C-D104768A1214");

int main(int argc, const char * argv[]) {

    //throws compile error: non-const lvalue reference to type 'BLECharacteristic' cannot bind to a value of unrelated type 'BLECharacteristic'
    ledService.addCharacteristic(myFailedChar);

    //Does not throw compile error.
    ledService.addCharacteristic(myWorkingChar);

    return 0
}