Repeated struct definitions for graph data structures and in/out naming conflict in C library

data pulverizer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 3 05:30:06 PST 2016


Dear D Gurus,

I am trying to access functionality in the glpk C library using 
extern(C). It has graph structs in its header file that are 
specified in an odd recurring manner that I cannot reproduce in D:

typedef struct glp_graph glp_graph;
typedef struct glp_vertex glp_vertex;
typedef struct glp_arc glp_arc;

struct glp_graph
{
      ...
       glp_vertex **v; /* glp_vertex *v[1+nv_max];
};

struct glp_vertex
{
       ...
       glp_arc *in;
       glp_arc *out;
};

struct glp_arc
{
       glp_vertex *tail;
       glp_vertex *head;
       glp_arc *t_prev;
       glp_arc *t_next;
       glp_arc *h_prev;
       glp_arc *h_next;
       ....
};


you may also spot that the in, and out keywords are used as 
members in the struct, which gives an error in D. These structs 
are required for functions in the library so need to be included 
in the D interface file.

How do I reproduce these structs in in D?

Thanks


More information about the Digitalmars-d-learn mailing list