#ifndef ... #endif: 'endif' does not name a type

It seems there’s something slightly picky with this compiler compared to Arduino. Whenever I try to do something simple like the code below, I get an error: ‘endif’ does not name a type. The offending block is:

#ifndef ARDUINO_H
#define ARDUINO_H
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#endif

If I move the #include statements outside the #ifndef#endif block, it compiles fine. Is this just a nuance in the compiler or could it be a fixable bug?

Thanks for distilling this @wgbartley. Good question.

The answer to your question of whether this is a nuance or fixable bug would likely be some where in the depths of this beauty:

https://launchpad.net/gcc-arm-embedded

This is the compiler used to build SparkCore firmware via both the Web IDE or manually.

@jgoggins: Well the code compiles fine, if you just do it via with gcc from the commandline… But not when doing it from the web IDE. So I guess there is something the web IDE is doing different or even wrong.

@stevie Yeah this is probably due to our pre-processor, which does the work of taking an Arduino-like syntax and makes it a complete C++ file (with a #include and function prototypes). I’ll add this to the list of issues to look into within the pre-processor.

Yes, that’s what I figured as well. Thanks!

Hey guys,

Sorry about the lateness of the fix, but I wanted to pop back in here and let you know this has been fixed and rolled out to production. Thank you!

Guys, maybe you can make some button in web IDE to look on pre-processor modified code. With this feauture we will can debug this errors by ourselves. For now - i just can’t debug my code correctly, because compiler warns me on lines in pre-processed code, and it not exactly same as in my code…

Hi @ekbduffy,

I think that’d be very helpful! I think the pre-processor should be ignoring .h and .cpp files and it’s not doing that at the moment. If you want it to leave you alone, just add this to your file:

#pragma SPARK_NO_PREPROCESSOR 

Thanks!
David