Why doesn't CGo recognize my struct declared in a header file?

dimlee :

I am getting the error "./test.h:10:3: error: unknown type name 'PROCESS'" when I include my header file test.h that has the struct definition PROCESS as a part of my C Go Lang application. The code compiles in C with no problems so I imagine I'm doing something very 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 are 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 we care about
    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;

};
Clifford :

In C, (unlike C++), the struct keyword does not declare a type-name that can be used on its own; it needs qualification with the struct keyword. The type is struct PROCESS not PROCESS:

struct PROCESS 
{
    char* name ;
    int os_type ;
    addr_t address ;
    struct PROCESS* next ;   // The struct keyword is needed here
    ...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From PHP

Why my php file doesn't recognize a session?

From Dev

Why doesn't weblate recognize my pot file?

From Dev

Why doesn't the packed length of my data correspond to what was declared in the struct?

From Dev

Why Make doesn't recognize my variable?

From

Why doesn't this JSON decode into my struct?

From

Why doesn't my struct code work?

From Dev

Why Ubuntu 12.10 doesn't recognize my graphic card?

From Dev

Why doesn't Rubymine recognize my namespaced inherited controller?

From Dev

Why doesn't my bash terminal recognize any command in the shell?

From Java

Why doesn't picocli recognize my option from the command line?

From Dev

Why IntelliJ doesn't recognize my main method?

From Java

Why doesn't IntelliJ Idea recognize my Spek tests?

From Dev

Why my actions on Google doesn't recognize touch selection?

From Dev

Why doesn't my Bash script recognize aliases?

From Dev

Why doesn't my compiler recognize #include <thread> (c++)?

From Dev

Why doesn't python 2.7.10 recognize my .pystartup and .inputrc?

From Dev

Why doesn't SimpleCov recognize my module tests?

From Dev

Why doesn't LWJGL recognize my GLFW version?

From Dev

My app doesn't recognize data from model file

From Dev

Why won't Ghostscript recognize my modified 'cidfmap' file?

From Dev

Why Pycharm won't recognize my python file?

From

Function doesn't recognize Yaml nested struct

From Dev

Why doesn't my Swift struct property appear in framework?

From Dev

Why doesn't my struct live long enough?

From Dev

Why doesn't my C struct get any data in input?

From Dev

Why doesn't my .desktop file work?

From Dev

Why templates declared in the struct on the header dont violate ODR and specialization does?

From Dev

Why lambda function doesn't output my header in the test?

From Dev

Why doesn't my makefile with include header work?

Related Related

  1. 1

    Why my php file doesn't recognize a session?

  2. 2

    Why doesn't weblate recognize my pot file?

  3. 3

    Why doesn't the packed length of my data correspond to what was declared in the struct?

  4. 4

    Why Make doesn't recognize my variable?

  5. 5

    Why doesn't this JSON decode into my struct?

  6. 6

    Why doesn't my struct code work?

  7. 7

    Why Ubuntu 12.10 doesn't recognize my graphic card?

  8. 8

    Why doesn't Rubymine recognize my namespaced inherited controller?

  9. 9

    Why doesn't my bash terminal recognize any command in the shell?

  10. 10

    Why doesn't picocli recognize my option from the command line?

  11. 11

    Why IntelliJ doesn't recognize my main method?

  12. 12

    Why doesn't IntelliJ Idea recognize my Spek tests?

  13. 13

    Why my actions on Google doesn't recognize touch selection?

  14. 14

    Why doesn't my Bash script recognize aliases?

  15. 15

    Why doesn't my compiler recognize #include <thread> (c++)?

  16. 16

    Why doesn't python 2.7.10 recognize my .pystartup and .inputrc?

  17. 17

    Why doesn't SimpleCov recognize my module tests?

  18. 18

    Why doesn't LWJGL recognize my GLFW version?

  19. 19

    My app doesn't recognize data from model file

  20. 20

    Why won't Ghostscript recognize my modified 'cidfmap' file?

  21. 21

    Why Pycharm won't recognize my python file?

  22. 22

    Function doesn't recognize Yaml nested struct

  23. 23

    Why doesn't my Swift struct property appear in framework?

  24. 24

    Why doesn't my struct live long enough?

  25. 25

    Why doesn't my C struct get any data in input?

  26. 26

    Why doesn't my .desktop file work?

  27. 27

    Why templates declared in the struct on the header dont violate ODR and specialization does?

  28. 28

    Why lambda function doesn't output my header in the test?

  29. 29

    Why doesn't my makefile with include header work?

HotTag

Archive