0

I want to use C library in Go. In order to execute C function I need to create C struct. I do it as follows:

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")
}

When I execute the code I got an error:

./main.go:8:2: error: expected specifier-qualifier-list before ‘std’
    8 |  std::uint16_t x;
      |  ^~~

How should I modify my code to use above struct?

3
  • 1
    Not sure why you have std:: before the struct variable names. That's not valid C. What happends if you remove that from both the variables? Commented Oct 27, 2020 at 19:02
  • See - golang struct with C struct in CGO Commented Oct 27, 2020 at 19:07
  • @Inian you were right, with std::, it isn't necessary. I removed it and it works. Thank you. Commented Oct 27, 2020 at 19:14

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.