Arduino-CmdMessenger icon indicating copy to clipboard operation
Arduino-CmdMessenger copied to clipboard

compile error

Open sslupsky opened this issue 6 years ago • 8 comments

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 avatar Sep 14 '19 18:09 sslupsky

I am using the arduino CLI to compile.

arduino-cli Version: 0.3.7-alpha.preview

sslupsky avatar Sep 14 '19 18:09 sslupsky

The target is a MKRWAN1300 that uses the SAMD21 mcu.

sslupsky avatar Sep 14 '19 18:09 sslupsky

same with stm32duino

ganjoe avatar Oct 03 '19 20:10 ganjoe

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';

adamj537 avatar Sep 08 '21 23:09 adamj537

original:

return '\0';

hmmm...:

return NULL;

better:

return nullptr;

CombiesGit avatar Mar 05 '22 11:03 CombiesGit

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.

Erhannis avatar Apr 27 '24 10:04 Erhannis