You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
definition of some C.name symbols are not known in advance from the go code itself:
C.struct_sockaddr
C.socklen_t
C.getnameinfo
C.char
C.socklen_t
C.NI_NAMEREQD
Type of some of the symbols can be determined based on they context:
C.struct_sockaddr and C.socklen_t are data types as they are part of a function signature definition
C.getnameinfo is function as it has used in a call expression and has more than one argument
C.char is a data type as char is C language keyword for char type
Some can not:
C.socklen_t: is it a function call or a data type casting? Given it is used as an parameter type, it is a type
C.NI_NAMEREQD: is it a variable or a pointer to a function?
Man page for getnameinfo says:
NAME
getnameinfo - address-to-name translation in protocol-independent manner
SYNOPSIS
#include<sys/socket.h>
#include<netdb.h>
int getnameinfo(const struct sockaddr *addr, socklen_t addrlen,
char *host, socklen_t hostlen,
char *serv, socklen_t servlen, int flags);
So one can deduce:
C.NI_NAMEREQD is expected to be a variable of type in as there is no call expression
One can process header files sys/types.h, sys/socket.h and netdb.h to get a list of types, variables/constants and functions. E.g. for each C header that is used in a go file provide a special file (e.g. sys/types.g.yaml) with C symbol definitions (just for illustration, types and functions are defined across multiple header file):
Given
/usr/lib/golang/src/net/cgo_resnew.go
from stdlib:definition of some C.name symbols are not known in advance from the go code itself:
C.struct_sockaddr
C.socklen_t
C.getnameinfo
C.char
C.socklen_t
C.NI_NAMEREQD
Type of some of the symbols can be determined based on they context:
C.struct_sockaddr
andC.socklen_t
are data types as they are part of a function signature definitionC.getnameinfo
is function as it has used in a call expression and has more than one argumentC.char
is a data type aschar
is C language keyword forchar
typeSome can not:
C.socklen_t
: is it a function call or a data type casting? Given it is used as an parameter type, it is a typeC.NI_NAMEREQD
: is it a variable or a pointer to a function?Man page for
getnameinfo
says:So one can deduce:
C.NI_NAMEREQD
is expected to be a variable of typein
as there is no call expressionOne can process header files
sys/types.h
,sys/socket.h
andnetdb.h
to get a list of types, variables/constants and functions. E.g. for each C header that is used in a go file provide a special file (e.g.sys/types.g.yaml
) with C symbol definitions (just for illustration, types and functions are defined across multiple header file):Or, the
yaml
file can be defined per cgo go file as well ascgo_resnew.go.yaml
or per multiple cgo files ascgo.yaml
.Additional links
The text was updated successfully, but these errors were encountered: