Skip to content

Instantly share code, notes, and snippets.

@nasitra
Created March 4, 2016 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nasitra/5d0095068db7423086a3 to your computer and use it in GitHub Desktop.
Save nasitra/5d0095068db7423086a3 to your computer and use it in GitHub Desktop.
Test C++ code by using Go language
#include <iostream>
#include "foo.h"
void Foo::print() {
std::cout << "foo\n";
}
extern "C" void Foo_print() {
Foo t;
t.print();
}
package foo
/*
#cgo CXXFLAGS: -std=c++11
#include "foo.h"
*/
import "C"
func fooPrint() {
C.Foo_print()
}
#ifndef _FOO_H
#define _FOO_H
#ifdef __cplusplus
class Foo {
public:
void print();
};
extern "C" {
#endif
void Foo_print();
#ifdef __cplusplus
}
#endif
#endif
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