Bug: warning emitted when compiling "cast-number-to-string"

Compiling automatically generated source for the Uno under the latest Arduino IDE containing a “cast-number-to-string” node feeding “console-log” I get the following compiler warning (first time a project using only nodes from the core library has caused anything but normal compilation for me):

In file included from /home/matt/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/eeprom.h:50:0,
from /home/matt/.arduino15/packages/arduino/hardware/avr/1.6.20/cores/arduino/USBAPI.h:25,
from /home/matt/.arduino15/packages/arduino/hardware/avr/1.6.20/cores/arduino/Arduino.h:233,
from /home/matt/Arduino/Projects/XodTest/XodTest.ino:18:
/home/matt/Arduino/Projects/XodTest/XodTest.ino:1117:94: warning: invalid access to non-static data member ‘xod::xod__core__cast_number_to_string::Storage::output_OUT’ of NULL object [-Winvalid-offsetof]
using output_OUT = OutputDescriptor<XString, offsetof(Wiring, output_OUT), offsetof(Storage, output_OUT), 0>;
^
/home/matt/Arduino/Projects/XodTest/XodTest.ino:1117:94: warning: (perhaps the ‘offsetof’ macro was used incorrectly) [-Winvalid-offsetof]

Edit: looks like from looking at the transpiled code the console-log node is not being generated, so maybe not an error of the type I thought it was with that particular node, but actually by design? From looking at the internals of the “console-log” node it seems like it should work OK when transpiled in addition to within the XOD debugger. I guess this goes back to my original problem with serial transmission but I’d been using the internal XOD serial debugging OK not realizing that code wasn’t being generated when transpiled. I guess?

Thanks for the report! Will take a look. A quick research shows this is due to using templates (not a Plain Old Data) to represent strings:

-Wno-invalid-offsetof (C++ and Objective-C++ only)
Suppress warnings from applying the ‘offsetof’ macro to a non-POD type.
According to the 1998 ISO C++ standard, applying ‘offsetof’ to a non-POD type is undefined. In existing C++ implementations, however, ‘offsetof’ typically gives meaningful results even when applied to certain kinds of non-POD types. (Such as a simple ‘struct’ that fails to be a POD type only by virtue of having a constructor.) This flag is for users who are aware that they are writing nonportable code and who have deliberately chosen to ignore the warning about it.
The restrictions on ‘offsetof’ may be relaxed in a future version of the C++ standard.

I’m pretty sure there’s no functionality problems which could be caused by it in XOD context.

1 Like

It seems that in general there isn’t a way to output data to the hardware serial port when transpiling code? That is to say in a situation where the serial port isn’t intended for just debugging execution but for say data logging in the actual functionality of the program, etc.

I haven’t really needed to use that for my project but in the meantime I’ve toyed with several approaches to accomplishing it and for whatever reason I can’t seem to get it to work. :sweat: Maybe I’m just thick on this issue but if anyone has an example that I could follow that’d be great!

Yep, there are no nodes for this (yet). However, you can make one for yourself (and community). Take a look how the watch node is done. Copy it and adopt the new one to send data unconditionally. If you need assistance with it, just tell.

Good weekends and Merry Christmas!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.