leftCoast/LC_lilParser

returnStr was not declared

maujabur opened this issue · 12 comments

Hi!
I just installed the library using the libray managar.
I'm on arduino 1.8.19 and when I try to compile the simple_parser_example I get the following:

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-IC:\\Users\\Fn\\Documents\\Arduino\\libraries\\LC_lilParser\\src" "-IC:\\Users\\Fn\\Documents\\Arduino\\libraries\\LC_baseTools" "C:\\Users\\Fn\\Documents\\Arduino\\libraries\\LC_lilParser\\src\\lilParser.cpp" -o "C:\\Users\\Fn\\AppData\\Local\\Temp\\arduino_build_262890\\libraries\\LC_lilParser\\lilParser.cpp.o" C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp: In destructor 'virtual lilParser::~lilParser()': C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp:32:16: error: 'returnStr' was not declared in this scope resizeBuff(0,&returnStr); ^~~~~~~~~ C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp: In member function 'char* lilParser::getParam()': C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp:136:36: error: 'returnStr' was not declared in this scope if (resizeBuff(getParamSize()+1,&returnStr)) { // If we can get the memory. ^~~~~~~~~ C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp:149:9: error: 'returnStr' was not declared in this scope return returnStr; // Pass back the result. ^~~~~~~~~ C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp: In member function 'char* lilParser::getParamBuff()': C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp:159:35: error: 'returnStr' was not declared in this scope if (resizeBuff(getParamSize()+1,&returnStr)) { // If we can get the memory. ^~~~~~~~~ C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp:169:9: error: 'returnStr' was not declared in this scope return returnStr; ^~~~~~~~~ C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp: In destructor 'virtual cmdTemplate::~cmdTemplate()': C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp:205:46: error: cannot convert 'char*' to 'char**' for argument '1' to 'void freeStr(char**)' cmdTemplate::~cmdTemplate(void) { freeStr(cmd); } ^ Usando a biblioteca LC_lilParser na versão 1.2 na pasta: C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser Usando a biblioteca LC_baseTools na versão 1.4 na pasta: C:\Users\Fn\Documents\Arduino\libraries\LC_baseTools

I tried going to version 1.1.0 and the same persists.
Also I took a look at the CPP file and returnStr is never declared over there

Hi!, thanks for your response.
Since the IDE had installed everything on the first run, I closed the IDE, deleted the folders from the library folder and installed on the order you suggested.
The problem seems to stay the same. Note the library versions at the end of the dump

C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp: In destructor 'virtual lilParser::~lilParser()': C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp:32:16: error: 'returnStr' was not declared in this scope resizeBuff(0,&returnStr); ^~~~~~~~~ C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp: In member function 'char* lilParser::getParam()': C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp:136:36: error: 'returnStr' was not declared in this scope if (resizeBuff(getParamSize()+1,&returnStr)) { // If we can get the memory. ^~~~~~~~~ C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp:149:9: error: 'returnStr' was not declared in this scope return returnStr; // Pass back the result. ^~~~~~~~~ C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp: In member function 'char* lilParser::getParamBuff()': C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp:159:35: error: 'returnStr' was not declared in this scope if (resizeBuff(getParamSize()+1,&returnStr)) { // If we can get the memory. ^~~~~~~~~ C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp:169:9: error: 'returnStr' was not declared in this scope return returnStr; ^~~~~~~~~ C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp: In destructor 'virtual cmdTemplate::~cmdTemplate()': C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser\src\lilParser.cpp:205:46: error: cannot convert 'char*' to 'char**' for argument '1' to 'void freeStr(char**)' cmdTemplate::~cmdTemplate(void) { freeStr(cmd); } ^ Usando a biblioteca **LC_lilParser na versão 1.2** na pasta: C:\Users\Fn\Documents\Arduino\libraries\LC_lilParser Usando a biblioteca **LC_baseTools na versão 1.4** na pasta: C:\Users\Fn\Documents\Arduino\libraries\LC_baseTools exit status 1 Erro compilando para a placa Arduino Uno

How did you learn about this stuff anyway?

-jim lee

If you mean how did I find the library, I just googled "arduino stream parser -json" and the second reult was your library on the arduino page:

From there I went to read the github repository and saw that you don't like the zip libraries, then I installed using the manager. Personally I've never had any problems with ZIP libraries nor just copying the folders to another computers

You know what? You are absolutely right! I was SURE returnStr was in the current released version, but I guess it isn't. Damn! Give me a bit and I'll see if I can cook you up a fresh copy that'll work.

I rolled a release 1.5 that should work. Let me know. Sorry about screwing you up and (silently) thinking it was all your fault.

returnStr is a global char* that is shared by any function that wants to return a char*. The thing is anything can grab it and reallocate it. If you just want to use it for something like.. atoi() to resolve an int? It'll work fine for stuff like that
Ex: newVal = atoi(mParser.getParam()); << This is legal use of returnStr.
But, if you are not sure what is going to use that return string? You had better do a local copy. Because you never know who my grab it and reallocate its memory. See tempStr & heapStr for handy tools if you run into this kind of issue.

Thanks! I'll try it now.

I was every now and then looking for a parser and yours seems to be it. Plus the base tools are probably going to be on my "utility belt"

I'll let you know about the release in a few minutes.

As soon as gihub updates

I guess you could try the .zip file. I just had so many issues from newbies screwing up library installs using .zip files.

This error has been fixed!

Good! I hope it works out for you!

Actually there was another unrelated error that keeps appearing. I just opened another issue. Please let me know if I can compensate you in some way for your help. Thanks a bunch again