c - Why doesn't CGo recognize my struct declared in a header file? -
i getting error "./test.h:10:3: error: unknown type name 'process'" when include header file test.h has struct definition process part of c go lang application. code compiles in c no problems imagine i'm doing simple incorrectly...
package main // #include <sys/mman.h> // #include <errno.h> // #include <inttypes.h> // #include <stdlib.h> // #include "test.h" import "c" import ( "fmt" _"unsafe" ) func main() { fmt.println("retrieving process list"); }
the contents of test.h below...
#include <sys/mman.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> struct process { char *name; int os_type; addr_t address; process *next; //fields care unsigned int uid; unsigned int gid; unsigned int is_root; unsigned int io_r; unsigned int io_wr; unsigned int io_sys_r; unsigned int io_sys_wr; unsigned int used_super; unsigned int is_k_thread; unsigned int cpus; unsigned long hw_rss; unsigned long vma_size; unsigned long map_count; unsigned long pages; unsigned long total_map; unsigned long min_flt; unsigned long mm_usrs; unsigned long nr_ptes; unsigned long nvcsw; };
in c, (unlike c++), struct
keyword not declare type-name can used on own; needs qualification struct
keyword. the type struct process
not process
:
struct process { char* name ; int os_type ; addr_t address ; struct process* next ; // struct keyword needed here ...
Comments
Post a Comment