Skip to content

Function prototype generator ignores "static" keyword #4123

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
nickgammon opened this issue Nov 10, 2015 · 2 comments
Closed

Function prototype generator ignores "static" keyword #4123

nickgammon opened this issue Nov 10, 2015 · 2 comments
Labels
Type: Duplicate Another item already exists for this topic
Milestone

Comments

@nickgammon
Copy link

See forum post: http://forum.arduino.cc/index.php?topic=358602

Example code:

static void doSomething()
{

}

void setup() {
  doSomething();
}

void loop() {

}

Generates errors in IDE 1.6.6:

/tmp/arduino_06b29c2745641c533fb2062c298c350d/sketch_nov10a.ino: In function 'void doSomething()':
sketch_nov10a:2: error: 'void doSomething()' was declared 'extern' and later 'static' [-fpermissive]
 static void doSomething()
                         ^
sketch_nov10a:2: error: previous declaration of 'void doSomething()' [-fpermissive]
 static void doSomething()
      ^
exit status 1
'void doSomething()' was declared 'extern' and later 'static' [-fpermissive]

The user did not in fact declare something one way and later another way.

Generated code from the IDE:

#include <Arduino.h>
#line 1
#line 1 "/tmp/arduino_06b29c2745641c533fb2062c298c350d/sketch_nov10a.ino"

void doSomething();
void setup();
void loop();
#line 2
static void doSomething()
{

}

void setup() {
  doSomething();
}

void loop() {

}

The "static" keyword was dropped from the generated prototype.


It is perfectly valid to add "static" to a function definition, in order to stop that function name from clashing with functions named the same in other compilation units.

@nickgammon
Copy link
Author

This same code compiles OK in IDE 1.6.5.

It would be nice if you tested changes to the function prototype-generator to make sure that code does not break from one minor release of the IDE to another. Maybe have some regression testing suites?

In IDE 1.6.5 this is what the generated output from the IDE is:

#line 1 "sketch_nov10c.ino"
#include "Arduino.h"
static void doSomething();
void setup();
void loop();
#line 1
static void doSomething()
{

}

void setup() {
  doSomething();
}

void loop() {

}

It looks like someone deliberately removed the support for "static".

@ffissore
Copy link
Contributor

Thank you @nickgammon This was reported in #4079 and fixed. Fix is available with hourly builds and will become part of 1.6.7

@ffissore ffissore added the Type: Duplicate Another item already exists for this topic label Nov 10, 2015
@ffissore ffissore added this to the Release 1.6.7 milestone Nov 10, 2015
@ffissore ffissore self-assigned this Nov 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Duplicate Another item already exists for this topic
Projects
None yet
Development

No branches or pull requests

2 participants