Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在'之前应为说明符限定符列表;std&x27;在cgo中_Go_Cgo - Fatal编程技术网

在'之前应为说明符限定符列表;std&x27;在cgo中

在'之前应为说明符限定符列表;std&x27;在cgo中,go,cgo,Go,Cgo,我想在围棋中使用C库。为了执行C函数,我需要创建C结构。我的做法如下: package main /* #include <stdint.h> typedef struct { std::uint16_t x; std::uint16_t y; } HeliosPoint; */ import "C" import "fmt" func main() { fmt.Println("hello world

我想在围棋中使用C库。为了执行C函数,我需要创建C结构。我的做法如下:

package main

/*
#include <stdint.h>

typedef struct
{
    std::uint16_t x;
    std::uint16_t y;
} HeliosPoint;
*/
import "C"

import "fmt"

func main() {
    fmt.Println("hello world")
}

我应该如何修改代码以使用上述结构?

不确定为什么在结构变量名称之前有
std::
。这不是有效的C。如果从两个变量中删除它,会发生什么?请参阅-@Inian you were right,对于
std::
,这是不必要的。我把它取下来,它就工作了。非常感谢。
./main.go:8:2: error: expected specifier-qualifier-list before ‘std’
    8 |  std::uint16_t x;
      |  ^~~