Skip to content

Prototypes for methods with default arguments are not generated [imported] #386

Closed
@cmaglie

Description

@cmaglie

This is Issue 386 moved from a Google Code project.
Added by 2010-10-23T13:23:50.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Defect, Priority-Medium, Component-PreProcessor

Original description

Steps to reproduce the issue:

STEP 1. Insert the following code into a blank sketch:

void setup() {
  test(42);
  test2(42);
}

void loop() {}
void test(int arg) {};
void test2(int arg = 0) {};

STEP 2: Click the verify button and observe the error message:

DefaultArgBugDemo.cpp: In function 'void setup()':
DefaultArgBugDemo:2: error: 'test2' was not declared in this scope

STEP 3:
Examine the generated *.cpp file and observe that a prototype has been generated for test1 but not test2:

#include "WProgram.h"
void setup();
void loop();
void test(int arg);
void setup() {
  test(42);
  test2(42);
}

void loop() {}
void test(int arg) {};
void test2(int arg = 0) {};

What is the expected output? What do you see instead?

You would expect a prototype to be generated for test2.

What version of the Arduino software are you using? On what operating
system? Which Arduino board are you using?

Tested in 0018 and 0021. Running on Win7 Home Premium (though the issue likely exists on all platforms)

Please provide any additional information below.

Of course the workaround is relatively simple (just define the prototype yourself) but it would be nice for all methods to be treated equally.

Metadata

Metadata

Assignees

Labels

Component: PreprocessorThe Arduino sketch preprocessor converts .ino files into C++ code before compilationType: WontfixArduino has decided that it will not resolve the reported issue or implement the requested feature

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions