Skip to content

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

Closed
@cmaglie

Description

@cmaglie

This is Issue 297 moved from a Google Code project.
Added by 2010-07-22T00:52:26.000Z by GorillaCoder.
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Defect, Priority-Medium

Original description

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 )

Metadata

Metadata

Assignees

Labels

Component: PreprocessorThe Arduino sketch preprocessor converts .ino files into C++ code before compilation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions