Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cmaglie opened this issue Nov 15, 2012 · 2 comments
Closed
Assignees
Labels
Component: Preprocessor The Arduino sketch preprocessor converts .ino files into C++ code before compilation
Milestone

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

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 )

@ffissore ffissore added the New label Feb 27, 2014
@ffissore ffissore added the Component: Preprocessor The Arduino sketch preprocessor converts .ino files into C++ code before compilation label Jan 20, 2015
@ffissore
Copy link
Contributor

Posted answer on googlecode

@ffissore ffissore self-assigned this Jan 28, 2015
@ffissore ffissore modified the milestone: Release 1.6.5 Jun 5, 2015
@ffissore
Copy link
Contributor

Fixed by #3779

@ffissore ffissore added this to the Release 1.6.6 milestone Sep 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Preprocessor The Arduino sketch preprocessor converts .ino files into C++ code before compilation
Projects
None yet
Development

No branches or pull requests

3 participants