C++11 cgo不';不包括CXXFLAGS

C++11 cgo不';不包括CXXFLAGS,c++11,go,cgo,C++11,Go,Cgo,我想调用Golang中的C代码: // #cgo CFLAGS: -I/usr/include/c++/8.1.1/bits // #cgo CXXFLAGS: -std=gnu++11 // #include "c++0x_warning.h" import "C" 但是得到错误: In file included from ./main.go:5: /usr/include/c++/8.1.1/bits/c++0x_warning.h:32:2: error: #error This fi

我想调用Golang中的C代码:

// #cgo CFLAGS: -I/usr/include/c++/8.1.1/bits
// #cgo CXXFLAGS: -std=gnu++11
// #include "c++0x_warning.h"
import "C"
但是得到错误:

In file included from ./main.go:5:
/usr/include/c++/8.1.1/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
所以cgo不使用CXXFLAGS。我试过
-std=c++11
,但它也不起作用。我做错了什么

$ go version
go version go1.10.3 linux/amd64

请参考以下SO问题:找出在程序上下文中真正需要的标志

如果你调用纯C代码(而不是C++代码),我认为你不需要<代码> CXXYFLAG/<代码>:

cppfags
应该是C预处理器的标志<代码> CXXFLAGS < /Cord>是C++编译器的标志。 您可能还需要检查您的
go-env
。如果确实需要此标志,可以尝试使用
env CGO\u cxflags=“-std=c++11”go build
编译程序