2010-07-07 9 views
0

이 라이브러리를 사용하여 부동 소수점을 문자열로 변환합니다 : http://www.arduino.cc/playground/Main/FloatToString?action=sourceblock&ref=1.Float to String Arduino 컴파일 오류

float flt = tempSensor.getTemperature(); 
    char buffer[25]; 
    char str[20]; 
    Serial.print(floatToString(str, flt, 2, 10)); 

이 상자 밖으로 작동해야하지만하지 않습니다 - 나는 짜서 일을 할 않았다

이 코드의 조각 밖으로 인쇄 할 경우, FLT는 "29.37"처럼 보인다? 당신이 값이 누락있는 것처럼

 
.../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 
+0

나는 완전한 해결책을 줄 정도로 익숙하지 않지만,'floatToString' 함수에 대한 매개 변수가 누락되었다는 것이 문제입니다. – Earlz

답변

0

말 ++에 True 또는 False 추가 매개 변수는 기본값을 가질 수 있습니다 :

나쁜 조정 MUS 난 당신이 연결된 하나는 하나 현재 당신없는 추측, 기본 값은

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) { 

헤더를 확인이 지난 디폴트 값을 가지지 않는, 또는 마지막 두 매개 변수 :

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

OK : T는 기본값이 용도.

문제에 대한 또 다른 포인터가 있습니다. ito는 컴파일러가 알지 못합니다. 그것은 cstdlib에 있어야하므로 #include <cstdlib>가 빠져 있습니다. 헤더에 달려 있기 때문에 헤더에 넣을 것입니다.

0

default argument missing for parameter 5 of 'char* floatToString(char*, float, int, int, bool)

가 보이는 :이 내 컴파일 오류가 있습니다 floatToString(str, flt, 2, 10)

시도에만 모든 마지막이

C에서
+0

기본값은 false입니다. – jdehaan

+0

글쎄요. 거기 들어가야 해. –

0

동일한 오류 메시지가 표시되었습니다. 그것은 #include "floatToString.h"를 두 번, 내 .ino 파일에서 한 번 사용한 클래스 중 하나에서 나타납니다. 그 중 하나를 제거한 다음 오류 메시지가 사라졌습니다.