diff --git a/tests/embedded_c/main.go b/tests/embedded_c/main.go new file mode 100644 index 0000000..ac04721 --- /dev/null +++ b/tests/embedded_c/main.go @@ -0,0 +1,17 @@ +// Go cross compiler (xgo): Test file for embedded C snippets. +// Copyright (c) 2015 Péter Szilágyi. All rights reserved. +// +// Released under the MIT license. + +package main + +// #include +// +// void sayHi() { +// printf("Hello, embedded C!\n"); +// } +import "C" + +func main() { + C.sayHi() +} diff --git a/tests/embedded_cpp/main.go b/tests/embedded_cpp/main.go new file mode 100644 index 0000000..26a2b91 --- /dev/null +++ b/tests/embedded_cpp/main.go @@ -0,0 +1,13 @@ +// Go cross compiler (xgo): Test file for embedded C++ snippets. +// Copyright (c) 2015 Péter Szilágyi. All rights reserved. +// +// Released under the MIT license. + +package main + +// #include "snippet.h" +import "C" + +func main() { + C.sayHi() +} diff --git a/tests/embedded_cpp/snippet.cpp b/tests/embedded_cpp/snippet.cpp new file mode 100644 index 0000000..194ff17 --- /dev/null +++ b/tests/embedded_cpp/snippet.cpp @@ -0,0 +1,11 @@ +// Go cross compiler (xgo): Test implementation for embedded C++ snippets. +// Copyright (c) 2015 Péter Szilágyi. All rights reserved. +// +// Released under the MIT license. + +#include +#include "snippet.h" + +void sayHi() { + std::cout << "Hello, embedded C++!" << std::endl; +} diff --git a/tests/embedded_cpp/snippet.h b/tests/embedded_cpp/snippet.h new file mode 100644 index 0000000..e860273 --- /dev/null +++ b/tests/embedded_cpp/snippet.h @@ -0,0 +1,14 @@ +// Go cross compiler (xgo): Test header for embedded C++ snippets. +// Copyright (c) 2015 Péter Szilágyi. All rights reserved. +// +// Released under the MIT license. + +#ifdef __cplusplus +extern "C" { +#endif + +void sayHi(); + +#ifdef __cplusplus +} +#endif