-
Notifications
You must be signed in to change notification settings - Fork 56
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
Compiling Code Throws Warnings #104
Comments
note: I updated char* to const char* in device.h and device.cpp and the bulk of these warnings go away. spelunking through the remaining 4 or 5 in GEVCU.ino but again, not sure if these were oversights -- as the code elsewhere uses const char* -- of if these were intentional. |
these are the remaining errors. not as clear to me how to resolve, but will continue to dig. /Users/chad/Documents/Arduino/GEVCU/GEVCU.ino: In function 'void initializeDevices()': |
again, looks to be an issue with char* declarations in logger.h and logger.cpp now, getting very wary of making these changes... (as Logger is used everywhere) |
and maybe only specific to Logger::info?? |
It should be fine to do what you're doing. The code for GEVCU is partly kind of old and the good compiler warnings didn't trigger back then. So, we just kind of never did it right and the compiler didn't complain. Now it properly complains. It's best to make all the string constants "const" anyway as that ensures that they'll be left in FLASH instead of loaded into RAM where they needn't be. |
Problem is the declarations in logger.h and .cpp are tripping me up — I’m not a super coder. they are ‘char starvariableName’ (vs ‘charstar variableName’) and not close enough to the original code to get it to compile. After making changes to logger - all sort of things go hairy. |
What’s hairy?
In both logger.h and logger.cpp you should be able to change all "char *message” to “const char *message” in the method arguments without issues.
… On Feb 12, 2020, at 6:49 PM, Chad Maglaque ***@***.***> wrote:
Problem is the declarations in logger.h and .cpp are tripping me up — I’m not a super coder. they are char variableName (vs char variableName) and not close enough to the original code to get it to compile. After making changes to logger - all sort of things go hairy.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#104?email_source=notifications&email_token=AAVU4RPI4PHW2UF3ZRNPOSLRCSDHZA5CNFSM4KUDSUN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELS2TLQ#issuecomment-585476526>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAVU4RIPWTHE4BHLIRF5DLDRCSDHZANCNFSM4KUDSUNQ>.
|
I tried that and I got a raft of errors. I wasn’t sure if “const char *message” was a valid declaration. |
I downloaded Arduino IDE 1.8.11, and the latest GEVCU, installed the Due board and selected it and compiled. I then changed all the instances that gave warning and it compiled cleanly. If you change the function declaration in a .h, you need to also do the same in the .cpp file Here is there diff. hth
|
I will try this. Much thanks! |
got a subsequent similar error on ThottleDetector.cpp, but resolved in s similar way. now getting the following: sketch/MemCache.cpp: In member function 'boolean MemCache::Write(uint32_t, void*, uint16_t)': will take a run at these next |
disregard the last, it appears the Arduino IDE was parsing MemCache.cpp incorrectly and missing some of the declaration the first run through. compiling a second time, the warnings go away. |
Colin/Jack:
When compiling the GEVCU code, the latest version of the Arduino IDE (1.8.11) throws the following errors when writing text strings, logging, etc. - several dozen actually. (see below the fold)
obviously these are warnings and the code will still compile, but pretty cumbersome having to debug around these. appears to be a syntax issue between C/C++. one approach might be to use
const char* vs. char* in each of the declarations -- the issue is primarily setting commonName and when sending log messages -- there may be others, but that's as far as I've gotten through all the warnings.
your thoughts on whether this is a really BAD idea or other options you might suggest - as you've been closest to the code throughout.
note: I'm loathe to suppress the warnings in the IDE, etc. for obvious reasons, but if that's the only practical option...
sketch/CanBrake.cpp: In constructor 'CanBrake::CanBrake()':
sketch/CanBrake.cpp:40:13: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
commonName = "CANBus brake";
^
sketch/CanBrake.cpp: In member function 'virtual void CanBrake::setup()':
sketch/CanBrake.cpp:46:71: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
Logger::info("add device: CanBrake (id: %X, %X)", CANBRAKEPEDAL, this);
The text was updated successfully, but these errors were encountered: