Skip to content

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

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
igrr opened this issue Mar 12, 2016 · 1 comment
Closed
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: preprocessor Related to sketch preprocessing type: imperfection Perceived defect in any part of project

Comments

@igrr
Copy link

igrr 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
@facchinm
Copy link
Member

facchinm commented Oct 6, 2016

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

@facchinm facchinm reopened this Oct 6, 2016
@per1234 per1234 added conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: preprocessor Related to sketch preprocessing type: imperfection Perceived defect in any part of project labels Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: preprocessor Related to sketch preprocessing type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants