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

**URL:** <https://forum.xod.io/t/bug-warning-emitted-when-compiling-cast-number-to-string/286>\
**Category:** Uncategorized\
**Created:** [December 22, 2017, 2:31pm UTC](https://forum.xod.io/t/bug-warning-emitted-when-compiling-cast-number-to-string/286 "2017-12-22T14:31:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitrex](https://avatars.discourse-cdn.com/v4/letter/b/eada6e/32.png) [@bitrex](https://forum.xod.io/u/bitrex)\
**Post date:** [December 22, 2017, 2:31pm UTC](https://forum.xod.io/t/bug-warning-emitted-when-compiling-cast-number-to-string/286/1 "2017-12-22T14:31:24Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [December 22, 2017, 3:10pm UTC](https://forum.xod.io/t/bug-warning-emitted-when-compiling-cast-number-to-string/286/2 "2017-12-22T15:10:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bitrex](https://avatars.discourse-cdn.com/v4/letter/b/eada6e/32.png) [@bitrex](https://forum.xod.io/u/bitrex)\
**Post date:** [December 22, 2017, 3:46pm UTC](https://forum.xod.io/t/bug-warning-emitted-when-compiling-cast-number-to-string/286/3 "2017-12-22T15:46:24Z")

</div>

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. 😓 Maybe I’m just thick on this issue but if anyone has an example that I could follow that’d be great!

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [December 22, 2017, 4:03pm UTC](https://forum.xod.io/t/bug-warning-emitted-when-compiling-cast-number-to-string/286/4 "2017-12-22T16:03:52Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/eb7348baa04192c2ef932d1db54d44f09f8a7888.png) [@system](https://forum.xod.io/u/system)\
**Post date:** [December 24, 2017, 4:04pm UTC](https://forum.xod.io/t/bug-warning-emitted-when-compiling-cast-number-to-string/286/5 "2017-12-24T16:04:02Z")

</div>

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