-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
word() cast not working #360
Comments
that's not how you cast in c++ . this is how: |
See static_cast<>(), dynamic_cast, and reinterpret_cast, const_cast for the modern way. |
Thanks for the advise: This indeed also fixes the problem. Anyway, the compiler should complain instead of giving a link problem. This was a real pain to debug, it actually shown up when I was trying to port the ModbusMaster library to esp8266. All the best. |
Well, word(something) for the compiler mean you are trying to use the On Sun, May 31, 2015, 7:55 AM Rafael de Pelegrini Soares <
|
I agree that word(something) means a function call. The problem with that particular case is that the linker complains about 'makeWord' missing and not the original function 'word'. Thus, the compiler somehow understand this, but get confused in the link step... BTW, it works with the standard arduino compiler, the problem appears only with the esp version. |
I believe the original intent of the makeWord was not specifically for casting, it was meant as a means to abstract "making a word" from two bytes (endian abstraction). |
Dear all, first let me say that you are doing a great job on this!
The bug I found is very simple to reproduce with the following sketch:
void setup() {
uint8_t data = 1;
uint16_t data16 = word(data);
}
void loop() {
}
With the above code I'm getting unresolved symbols in the link step:
undefined reference to `makeWord(unsigned short)'
That should be probably easy to fix, but I don't know where...
I reproduced this problem on both Linux and Windows. For standard Arduino the code links fine.
The following equivalent code links fine with the esp8266:
void setup() {
uint8_t data = 1;
uint16_t data16 = uint16_t(data);
}
void loop() {
}
All the best.
The text was updated successfully, but these errors were encountered: