queezythegreat / arduino-cmake

Arduino CMake Build system
644 stars 216 forks source link

Build fails if first line of ino has code #37

Closed ichernev closed 12 years ago

ichernev commented 12 years ago

If the first line of the source file has code in it, in my case

int led = 13;

then the generated c++ file is invalid:

// automatically generated by arduino-cmake
#line 1 "/home/iskren/src/arduino/input/input.ino"
int led = 13;#line 1 "autogenerated"
#include "Arduino.h"
...

And this gives the following error:

/home/iskren/src/arduino/input/input.ino:1:1: error: stray '#' in program
/home/iskren/src/arduino/input/input.ino:1:15: error: 'line' does not name a type
...
/usr/lib/gcc/avr/4.7.0/../../../../avr/include/stdlib.h:143:61: error: 'size_t' has not been declared
/usr/lib/gcc/avr/4.7.0/../../../../avr/include/stdlib.h:144:8: error: 'size_t' has not been declared
/usr/lib/gcc/avr/4.7.0/../../../../avr/include/stdlib.h:175:33: error: 'size_t' has not been declared
...

If the first line of the file is a commen (or empty), then the #line 1 "autogenerated" text is on a new line, and it works.

queezythegreat commented 12 years ago

Hi, I've commited in the fix. Could you please confirm this fixes your issue.

ichernev commented 12 years ago

Thanks a lot! It works.