How are you cross-compiling this code, what command are you using? Are you using the latest version of gcc? What image are you using?
You can try updating gcc to the latest version from this repo Galileo Package Repo Configuration Instructions
I've tried using both gcc and the intel compiler that is setup when setting up the cross compile toolchain
I ran your code and didn’t see any errors. First I installed gcc from the repo I posted in my previous post. I created a file named testc.c and put your code in it. I ran the command
gcc testc.c –o testc
to create the executable file and then executed it using
Take a look at the picture attached.
I’m using the standard Yocto image.