Skip to content

Commit 5b29cb7

Browse files
committed
Merge pull request #128 from facchinm/extern_C_proto
Fix ` extern "C" ` prototype generation
2 parents ab082ad + e980cf4 commit 5b29cb7

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

Diff for: src/arduino.cc/builder/ctags/ctags_parser.go

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const KIND_FUNCTION = "function"
4747

4848
const TEMPLATE = "template"
4949
const STATIC = "static"
50+
const EXTERN = "extern \"C\""
5051

5152
var KNOWN_TAG_KINDS = map[string]bool{
5253
"prototype": true,
@@ -101,6 +102,9 @@ func addPrototype(tag *types.CTag) {
101102
if strings.Index(tag.Code, STATIC+" ") != -1 {
102103
tag.PrototypeModifiers = tag.PrototypeModifiers + " " + STATIC
103104
}
105+
if strings.Index(tag.Code, EXTERN+" ") != -1 {
106+
tag.PrototypeModifiers = tag.PrototypeModifiers + " " + EXTERN
107+
}
104108
tag.PrototypeModifiers = strings.TrimSpace(tag.PrototypeModifiers)
105109
}
106110

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
void setup() {
2+
// put your setup code here, to run once:
3+
test();
4+
}
5+
6+
void loop() {
7+
// put your main code here, to run repeatedly:
8+
9+
}
10+
11+
extern "C" void test() {}

Diff for: src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ func TestTryBuild036(t *testing.T) {
191191
tryBuildWithContext(t, context, "sketch11", "sketch_fastleds.ino")
192192
}
193193

194+
func TestTryBuild037(t *testing.T) {
195+
tryBuild(t, "sketch_with_externC", "sketch_with_externC.ino")
196+
}
197+
194198
func makeDefaultContext(t *testing.T) map[string]interface{} {
195199
DownloadCoresAndToolsAndLibraries(t)
196200

0 commit comments

Comments
 (0)