Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/128.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++ 浮点到字符串Arduino编译错误_C++_Compiler Errors_Arduino - Fatal编程技术网

C++ 浮点到字符串Arduino编译错误

C++ 浮点到字符串Arduino编译错误,c++,compiler-errors,arduino,C++,Compiler Errors,Arduino,我正在使用此库将浮点转换为字符串: 这是一段代码,其中打印flt看起来像29.37: float flt = tempSensor.getTemperature(); char buffer[25]; char str[20]; Serial.print(floatToString(str, flt, 2, 10)); 这应该是开箱即用的,但不是-我干了什么?以下是我的编译错误: .../floatToString.h:11: error: expected p

我正在使用此库将浮点转换为字符串:

这是一段代码,其中打印flt看起来像29.37:

    float flt = tempSensor.getTemperature();
    char buffer[25];
    char str[20];
    Serial.print(floatToString(str, flt, 2, 10));
这应该是开箱即用的,但不是-我干了什么?以下是我的编译错误:

.../floatToString.h:11: error: expected primary-expression before ',' token .../floatToString.h: In function 'char* floatToString(char*, float, int, int, bool)': .../floatToString.h:11: error: default argument missing for parameter 5 of 'char* floatToString(char*, float, int, int, bool)' .../floatToString.h:73: error: 'itoa' was not declared in this scope .../floatToString.h:89: error: 'itoa' was not declared in this scope “char*floatToStringchar*,float,int,int,bool”的参数5缺少默认参数

看起来您缺少一个值:floatToStringstr,flt,2,10


尝试在C++中添加true或false,

,只有所有最后的参数都允许有默认值:

char * floatToString(char * outstr, float value, int places,
    int minwidth=0, bool rightjustify) {
错误的rightjustify必须具有默认值:

char * floatToString(char * outstr, float value, int places,
    int minwidth=0, bool rightjustify) {
确定:没有默认值,最后一个或最后两个参数具有默认值

char * floatToString(char * outstr, float value, int places,
    int minwidth, bool rightjustify) {

char * floatToString(char * outstr, float value, int places,
    int minwidth, bool rightjustify=false) {

char * floatToString(char * outstr, float value, int places,
    int minwidth=0, bool rightjustify=false) {
检查你的标题,我猜你链接的不是你当前使用的标题


还有另一个指向问题的指针:编译器不知道ito。它应该在cstdlib中,因此缺少一个include,我会将它放在标题中,因为它依赖于它。

我收到了相同的错误消息;事实证明,我已经包含了两次floatToString.h,一次在我的.ino文件中,一次在我使用的一个类中。我删除了其中一个,然后相当误导性的错误信息消失了

我不太熟悉,无法给您提供完整的解决方案,但问题是您缺少函数floatToStringIt的一个参数,该函数的默认值为false