From 12c65efd7b2dd397d978d73b7ea03c500798d566 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Wed, 16 Mar 2016 17:07:27 +0100 Subject: [PATCH 1/2] fix (extern "C") prototype generation fixes #126 Signed-off-by: Martino Facchin --- src/arduino.cc/builder/ctags/ctags_parser.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/arduino.cc/builder/ctags/ctags_parser.go b/src/arduino.cc/builder/ctags/ctags_parser.go index 0a73391f..b756c3f5 100644 --- a/src/arduino.cc/builder/ctags/ctags_parser.go +++ b/src/arduino.cc/builder/ctags/ctags_parser.go @@ -47,6 +47,7 @@ const KIND_FUNCTION = "function" const TEMPLATE = "template" const STATIC = "static" +const EXTERN = "extern \"C\"" var KNOWN_TAG_KINDS = map[string]bool{ "prototype": true, @@ -101,6 +102,9 @@ func addPrototype(tag *types.CTag) { if strings.Index(tag.Code, STATIC+" ") != -1 { tag.PrototypeModifiers = tag.PrototypeModifiers + " " + STATIC } + if strings.Index(tag.Code, EXTERN+" ") != -1 { + tag.PrototypeModifiers = tag.PrototypeModifiers + " " + EXTERN + } tag.PrototypeModifiers = strings.TrimSpace(tag.PrototypeModifiers) } From e980cf4f3ef7309a66a6730373642948ba05feb5 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Fri, 25 Mar 2016 12:28:30 +0100 Subject: [PATCH 2/2] add test for sketch with `extern C` func declaration Signed-off-by: Martino Facchin --- .../test/sketch_with_externC/sketch_with_externC.ino | 11 +++++++++++ .../test/try_build_of_problematic_sketch_test.go | 4 ++++ 2 files changed, 15 insertions(+) create mode 100644 src/arduino.cc/builder/test/sketch_with_externC/sketch_with_externC.ino diff --git a/src/arduino.cc/builder/test/sketch_with_externC/sketch_with_externC.ino b/src/arduino.cc/builder/test/sketch_with_externC/sketch_with_externC.ino new file mode 100644 index 00000000..8e6c53ea --- /dev/null +++ b/src/arduino.cc/builder/test/sketch_with_externC/sketch_with_externC.ino @@ -0,0 +1,11 @@ +void setup() { + // put your setup code here, to run once: + test(); +} + +void loop() { + // put your main code here, to run repeatedly: + +} + +extern "C" void test() {} \ No newline at end of file diff --git a/src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go b/src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go index 08eccaf1..bac46ac5 100644 --- a/src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go +++ b/src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go @@ -191,6 +191,10 @@ func TestTryBuild036(t *testing.T) { tryBuildWithContext(t, context, "sketch11", "sketch_fastleds.ino") } +func TestTryBuild037(t *testing.T) { + tryBuild(t, "sketch_with_externC", "sketch_with_externC.ino") +} + func makeDefaultContext(t *testing.T) map[string]interface{} { DownloadCoresAndToolsAndLibraries(t)