-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <vector> | ||
|
||
using namespace::std; | ||
|
||
///////////////////////////////////////// | ||
//CWord | ||
///////////////////////////////////////// | ||
class CWord | ||
{ | ||
public: | ||
int m_nID; | ||
char* m_psWord; | ||
public: | ||
CWord(); | ||
~CWord(); | ||
}; | ||
|
||
CWord::CWord() | ||
{ | ||
m_psWord = NULL; | ||
m_nID = -1; | ||
} | ||
|
||
CWord::~CWord() | ||
{ | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# 使用g++编译dll给go调用 | ||
|
||
``` | ||
Windows 10 | ||
go version go1.12 windows/amd64 | ||
g++ (tdm64-1) 5.1.0 | ||
Copyright (C) 2015 Free Software Foundation, Inc. | ||
This is free software; see the source for copying conditions. There is NO | ||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
``` | ||
|
||
> mingw32-make.exe | ||
> go build | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "cwrap.h" | ||
#include "test.h" | ||
|
||
void call() { | ||
Test ctx; | ||
ctx.call(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef __CWRAP_H__ | ||
#define __CWRAP_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
void call(); | ||
|
||
#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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
/* | ||
#cgo CFLAGS: -Icpp | ||
#cgo LDFLAGS: -L. -lgotest | ||
#include "cwrap.h" | ||
*/ | ||
import "C" | ||
|
||
func main() { | ||
C.call() | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build: | ||
rm -f test.o | ||
gcc -c test.cpp -o test.o | ||
gcc -shared -o libgotest.dll test.o | ||
rm -f test.o |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "test.h" | ||
|
||
void Test::call() { | ||
printf("call from c++ language\n"); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef __TEST_H__ | ||
#define __TEST_H__ | ||
|
||
#include <stdio.h> | ||
|
||
class Test { | ||
public: | ||
void call(); | ||
}; | ||
|
||
#endif |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.