Hi, my question is, why call in cgo function, the parameters are
shifted by 1 from 2 and shows an error.
C code:
static inline dom_exception dom_document_rename_node(struct
dom_document *doc,
struct dom_node *node,
dom_string *namespace, dom_string *qname,
struct dom_node **result)
{
> Hi, my question is, why call in cgo function, the parameters are
> shifted by 1 from 2 and shows an error.
>
> C code:
>
> static inline dom_exception dom_document_rename_node(struct
> dom_document *doc,
> struct dom_node *node,
> dom_string *namespace, dom_string *qname,
> struct dom_node **result)
> {
> return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
> dom_document_rename_node(doc, node, namespace, qname,
> result);
> }
> #define dom_document_rename_node(d, n, ns, q, r)
> dom_document_rename_node( \
> (dom_document *) (d), (dom_string *) (ns), \
> (dom_string *) (q), (dom_node **) (r))
I believe cgo is going to see the actual function definition, not the
macro, and it is going to generate code that calls the function.
However, the generated C code will #include the header and will see the
macro; thus the generated code which expects to call the function will
call the macro instead. The function and the macro do not take the same
arguments.
Giving the same name to both a function and a macro but having them act
differently seems like a very confusing way to program.
Ian