//test.h
#ifndef TEST_H
#define TEST_H 1
#include <string>
class MPrint
{
public:
MPrint();
void Print(const std::string &msg);
void Print(const std::string &msg, bool flag);
};
#endif
//test.cpp
#include <iostream>
#include "test.h"
using namespace std;
MPrint::MPrint()
{
}
void MPrint::Print(const string &msg)
{
cout << msg << endl;
}
void MPrint::Print(const sting &msg, bool flag)
{
cout << flag << ": " << msg << endl;
}
//test_wrap.h
#include "test.h"
static MPrint mp;
void print(char *msg)
{
mp.Print(msg);
}
//mytest.go
package main
/*
#include "./test_wrap.h"
*/
import "C"
import (
"fmt"
)
func main() {
C.print(C.CString("hello, world"))
}
运行报错:
# command-line-arguments
In file included from ././test_wrap.h:2:0,
from ./mytest.go:4:
././test.h:3:18: fatal error: string: No such file or directory
compilation terminated.
请各位大佬帮忙答疑?
有疑问加站长微信联系(非本文作者)