I'm trying to wrap the Parma Polyhedron Library in Julia.

The library itself is written in C++, I am trying to wrap the C API.

Consider a snippet of an C example which uses the C API

static int
solve_with_generators(ppl_Constraint_System_t ppl_cs,
                      ppl_const_Linear_Expression_t ppl_objective_le,
                      ppl_Coefficient_t optimum_n,
                      ppl_Coefficient_t optimum_d,
                      ppl_Generator_t point) {
  ppl_Polyhedron_t ppl_ph;
  ...
  /* Create the polyhedron (recycling the data structures of ppl_cs). */
  ppl_new_C_Polyhedron_recycle_Constraint_System(&ppl_ph, ppl_cs);



To illustrate my problem, consider the call to* 
ppl_new_C_Polyhedron_recycle_Constraint_System* which creates a constraint 
system, and has signature: 

ppl_new_C_Polyhedron_recycle_Constraint_System(ppl_Polyhedron_t* pph, 
ppl_Constraint_System_t cs)



*ppl_Polyhedron_*t is typedef generated using macros, but effectively it is 
defined by

typedef struct ppl_Polyhedron_tag* ppl_Polyhedron_t;

I can't find anywhere in the source where these structs are defined, but 
presumably they must (my C is very rusty).  In any case, the problem is 
that from Julia I don't have access to these typedefs.  If I want to ccall 
*ppl_new_C_Polyhedron_recycle_Constraint_System*, what can I use as the 
first and second arguments?  My (currently very naive) intuition is that I 
need C functions which return values of the type *ppl_Polyhedron_t* for 
instance, but it seems this API does not follow that pattern.  Is this 
correct? Will I need to do something like write another C API which just 
returns pointers? Or is there a simpler solution?

Thanks

Reply via email to