I'm trying to access a c struct in cgo, but go this
could not determine kind of name for C.utmpx
utmpx is a c struct
here is the go code:
/*
#include <stdio.h>
#include <stdlib.h>
#include <utmpx.h>
#include <fcntl.h>
#include <unistd.h>
*/
import "C"
type record C.utmpx
fd, err := os.Open(C._PATH_UTMPX) // this works
fd, err := os.Open(C.UTMPX_FILE) // error
In the utmpx.h file , there is
#define _PATH_UTMPX "/var/run/utmpx"
#define UTMPX_FILE _PATH_UTMPX
I can use _PATH_UTMPX but get the same warn when using UTMPX_FILE, why?
It seems that I cannot access these variables declared in .h file How can i do this ?
platform: macOS sirria,go 1.8