Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile error #49

Open
sslupsky opened this issue Sep 14, 2019 · 6 comments
Open

compile error #49

sslupsky opened this issue Sep 14, 2019 · 6 comments

Comments

@sslupsky
Copy link

sslupsky commented Sep 14, 2019

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;

char* CmdMessenger::readStringArg()

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
Copy link
Author

I am using the arduino CLI to compile.

arduino-cli Version: 0.3.7-alpha.preview

@sslupsky
Copy link
Author

The target is a MKRWAN1300 that uses the SAMD21 mcu.

@ganjoe
Copy link

ganjoe commented Oct 3, 2019

same with stm32duino

@adamj537
Copy link

adamj537 commented Sep 8, 2021

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
Copy link

original:

return '\0';

hmmm...:

return NULL;

better:

return nullptr;

@Erhannis
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants