Created
March 4, 2016 10:56
-
-
Save nasitra/5d0095068db7423086a3 to your computer and use it in GitHub Desktop.
Test C++ code by using Go language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "foo.h" | |
void Foo::print() { | |
std::cout << "foo\n"; | |
} | |
extern "C" void Foo_print() { | |
Foo t; | |
t.print(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
/* | |
#cgo CXXFLAGS: -std=c++11 | |
#include "foo.h" | |
*/ | |
import "C" | |
func fooPrint() { | |
C.Foo_print() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _FOO_H | |
#define _FOO_H | |
#ifdef __cplusplus | |
class Foo { | |
public: | |
void print(); | |
}; | |
extern "C" { | |
#endif | |
void Foo_print(); | |
#ifdef __cplusplus | |
} | |
#endif | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
import "testing" | |
func TestFooPrint(t *testing.T) { | |
fooPrint() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment