jung6717 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Bad preprocessor expansion of sketch results in illegal c++ code. #297

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Try to compile the below sketch:
    class SleepCycle  {
    public:

        SleepCycle( const char* name );
        int foo;
    }; // class SleepCycle

    SleepCycle::SleepCycle( const char* name )
    :   foo    ( 0 )
    {
    }
The c++ compilation fails because the generated c++ is bad:
    include "WProgram.h"
    foo    ( 0 ); 
    class SleepCycle  {
    public:

        SleepCycle( const char* name );
        int foo;
    }; // class SleepCycle

    SleepCycle::SleepCycle( const char* name )
    :   foo    ( 0 )
    {   
    }   
It can be fixed by removing the spaces between the name and paren in the 
initializer for foo.
    :   foo( 0 )

Original issue reported on code.google.com by GorillaCoder on 22 Jul 2010 at 12:52

GoogleCodeExporter commented 9 years ago
I just bumped into this again. It's bloody hard to figure out what's going on 
when it bites you, as arduino puts you on a line of code that makes no sense, 
and the code there looks nothing like the complaint. I can figure it out. Pity 
the poor noob just trying to use classes.

Original comment by GorillaCoder on 12 Nov 2010 at 3:35

GoogleCodeExporter commented 9 years ago
Please checkout this thread [1] on devs mailing list and try one of the linked 
IDEs. 
https://groups.google.com/a/arduino.cc/d/msg/developers/4X2T3rCxXWM/WbQ2_dGzuhsJ

Original comment by federico...@gmail.com on 26 Jan 2015 at 3:15

GoogleCodeExporter commented 9 years ago
New preprocessor tracked at https://github.com/arduino/Arduino/pull/2636. 
Builds for testing it are available

Original comment by federico...@gmail.com on 13 Feb 2015 at 7:19

GoogleCodeExporter commented 9 years ago

Original comment by federico...@gmail.com on 26 May 2015 at 3:23