thijse / Arduino-CmdMessenger

CmdMessenger Communication library for Arduino & .NET
Other
208 stars 87 forks source link

compile error #49

Open sslupsky opened 5 years ago

sslupsky commented 5 years ago

Encountered the following error when attempting to compile a sketch using CmdMessenger:

Arduino-CmdMessenger/CmdMessenger.cpp:492:9: error: invalid conversion from 'char' to 'char*' [-fpermissive]
  return '\0';

The function is defined to return a pointer as follows; https://github.com/thijse/Arduino-CmdMessenger/blob/8c3c4446fa593b8ea96a350c99aa93e7b471fc82/CmdMessenger.cpp#L484

Since the function is returning a char instead of a pointer, this is causing a compiler error.

Should the correct return value be NULL? ie:

return NULL;

sslupsky commented 5 years ago

I am using the arduino CLI to compile.

arduino-cli Version: 0.3.7-alpha.preview

sslupsky commented 5 years ago

The target is a MKRWAN1300 that uses the SAMD21 mcu.

ganjoe commented 5 years ago

same with stm32duino

adamj537 commented 3 years ago

This library appears to have been written for the AVR compiler, which does not return any errors on this line. Atmel SAM compilers return an error.

I was able to compile for an Adafruit Feather M0 by changing the offending line to include a cast, as follows: return (char)'\0';

CombiesGit commented 2 years ago

original:

return '\0';

hmmm...:

return NULL;

better:

return nullptr;

Erhannis commented 7 months ago

original:

return '\0';

hmmm...:

return NULL;

better:

return nullptr;

Actually...that's a good point. Looking at the code, I think the author maybe intended to return an empty string - but instead effectively returned NULL. I'm not sure; I feel like it could go either way.