Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgo_helpers.h wont compile #8

Closed
proglottis opened this issue Sep 28, 2016 · 2 comments
Closed

cgo_helpers.h wont compile #8

proglottis opened this issue Sep 28, 2016 · 2 comments

Comments

@proglottis
Copy link

I found a case in gpgme that doesn't seem to generate cgo_helpers.h quite right. I've created a minimal example of it (no dependence on gpgme) to demonstrate.

gpgme.yml:

---
GENERATOR:
  PackageName: gpgme
  Includes: ["gpgme.h"]
PARSER:
  SourcesPaths: ["gpgme.h"]
TRANSLATOR:
  Rules:
    global:
      - {action: accept, from: "^gpgme_"}

gpgme.h:

typedef unsigned int gpg_error_t;
typedef gpg_error_t gpgme_error_t;
typedef gpgme_error_t (*gpgme_io_cb_t) (void *data, int fd);
typedef gpgme_error_t (*gpgme_register_io_cb_t) (void *data, int fd, int dir,
                         gpgme_io_cb_t fnc,
                         void *fnc_data, void **tag);

And here's the error:

$ rm -rf gpgme/ && cgogen gpgme.yml && go build ./gpgme
  processing gpgme.yml done.
# github.com/proglottis/autogpgme/gpgme
could not determine kind of name for C.fnc

clang errors for preamble:
In file included from gpgme/cgo_helpers.go:9:
./cgo_helpers.h:14:75: error: unknown type name 'fnc'
unsigned int gpgme_register_io_cb_t_de500e8c(void* data, int fd, int dir, fnc fnc, void* fnc_data, void** tag);
                                                                          ^
1 error generated.

The fnc fnc argument has the wrong type.

@xlab xlab closed this as completed in 33c46c2 Sep 28, 2016
@xlab
Copy link
Owner

xlab commented Sep 28, 2016

@proglottis much thanks for the report, it should be OK now! Be careful though with these callbacks.

@xlab
Copy link
Owner

xlab commented Sep 28, 2016

@proglottis
Also, please check out this Makefile to make life easier ;)
https://github.com/xlab/cgogen/wiki/Makefile-template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants