Skip to content
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

Forward declarations of extern "C" functions are not generated correctly #126

Closed
igrr opened this issue Mar 12, 2016 · 1 comment

Comments

2 participants
@igrr
Copy link

commented Mar 12, 2016

Trying to compile the following sketch:

extern "C" void test() {
}

void setup() {
  test();
}

void loop() {
}

Leads to an error:

/Users/igrokhotkov/Documents/Arduino/Bugreports/B1759_ExternC/B1759_ExternC.ino: In function 'void test()':
B1759_ExternC:1: error: previous declaration of 'void test()' with 'C++' linkage
 extern "C" void test() {
      ^
B1759_ExternC:1: error: conflicts with new declaration with 'C' linkage
 extern "C" void test() {
                      ^
exit status 1
previous declaration of 'void test()' with 'C++' linkage

arduino-builder output:
builder_output.txt

ctags output:
ctags_output.txt
Note that function signature looks correct in ctags output:
B1759_ExternC.ino /^extern "C" void test() {$/;" kind:function line:1 signature:() returntype:void

sketch with prototypes added:

#include <Arduino.h>
#line 1
#line 1 "/Users/igrokhotkov/Documents/Arduino/Bugreports/B1759_ExternC/B1759_ExternC.ino"
#line 1 "/Users/igrokhotkov/Documents/Arduino/Bugreports/B1759_ExternC/B1759_ExternC.ino"
void test();
#line 4 "/Users/igrokhotkov/Documents/Arduino/Bugreports/B1759_ExternC/B1759_ExternC.ino"
void setup();
#line 8 "/Users/igrokhotkov/Documents/Arduino/Bugreports/B1759_ExternC/B1759_ExternC.ino"
void loop();
#line 1
extern "C" void test() {
}

void setup() {
  test();
}

void loop() {
}

I'm not sure which version of Arduino introduced this issue, but this certainly worked fine in 1.6.5.

Original issue filed in our repository: esp8266/Arduino#1759

facchinm added a commit to facchinm/arduino-builder that referenced this issue Mar 16, 2016

facchinm added a commit to facchinm/arduino-builder that referenced this issue Mar 16, 2016

fix (extern "C") prototype generation
fixes arduino#126

Signed-off-by: Martino Facchin <m.facchin@arduino.cc>
@facchinm

This comment has been minimized.

Copy link
Member

commented Oct 6, 2016

Still not completely fixed as reported on #128 (declaration over n lines)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.