导入Cgo包中的C.scintilla_new()。

huangapple go评论87阅读模式
英文:

Importing C.scintilla_new() in Cgo package

问题

以下是翻译好的内容:

package main

//#cgo CFLAGS: -I/home/me/geany/scintilla/include
//#include <ScintillaWidget.h>
import "C"

import (
	"github.com/mattn/go-gtk/gtk"
)

func main() {
	gtk.Init(nil)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("GTK Go!")
	window.SetIconName("textview")
	window.Connect("destroy", gtk.MainQuit)
	window.SetSizeRequest(600, 600)
	C.scintilla_new();
	window.ShowAll()
	gtk.Main()
}

这是我得到的错误信息:

# _/home/me/gosci/gosci
无法确定 C.scintilla_new 的名称类型

在第58行的头文件中明显定义了它:

GtkWidget*	scintilla_new		(void);

如何编译这个代码?

英文:
package main

//#cgo CFLAGS: -I/home/me/geany/scintilla/include
//#include &lt;ScintillaWidget.h&gt;
import &quot;C&quot;

import (
	&quot;github.com/mattn/go-gtk/gtk&quot;
)

func main() {
	gtk.Init(nil)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle(&quot;GTK Go!&quot;)
	window.SetIconName(&quot;textview&quot;)
	window.Connect(&quot;destroy&quot;, gtk.MainQuit)
	window.SetSizeRequest(600, 600)
	C.scintilla_new();
	window.ShowAll()
	gtk.Main()
}

This is the error I get:

# _/home/me/gosci/gosci
could not determine kind of name for C.scintilla_new

The definition is obviously in the header at line 58:

GtkWidget*	scintilla_new		(void);

How to compile this?

答案1

得分: 1

可能在ScintillaWidget.h中没有声明GtkWidget,你需要先#include <gtk/gtk.h>

英文:

Possibly GtkWidget is not declared in ScintillaWidget.h and you need to #include &lt;gtk/gtk.h&gt; first.

huangapple
  • 本文由 发表于 2017年8月10日 14:42:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/45606288.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定