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

Error when generating from a certain syntax structure #355

Closed
KristofferC opened this issue Dec 14, 2021 · 3 comments · Fixed by #361
Closed

Error when generating from a certain syntax structure #355

KristofferC opened this issue Dec 14, 2021 · 3 comments · Fixed by #361
Labels

Comments

@KristofferC
Copy link
Contributor

KristofferC commented Dec 14, 2021

I have some code that structurally looks like:

typedef struct s {
} s;

int (*s_f(const struct s* n))(struct s*);

When trying to generate this I hit #354 because:

cursor = CLCursor (Clang.CLFunctionDecl) s_f(const struct s *)
args = Clang.CLCursor[CLCursor (Clang.CLParmDecl) , CLCursor (Clang.CLParmDecl) n]
types = Clang.CLType[CLType (Clang.CLPointer) , CLType (Clang.CLInvalid) ]

in

args = get_function_args(cursor)
types = CLType[getArgType(getCursorType(cursor), i - 1) for i in 1:length(args)]

@Gnimuc
Copy link
Member

Gnimuc commented Dec 14, 2021

@KristofferC I can't parse this C code int (*s_f(const struct s* n))(struct s*);

https://cdecl.org also gives a syntax error.

@melonedo
Copy link
Contributor

@KristofferC I can't parse this C code int (*s_f(const struct s* n))(struct s*);

https://cdecl.org also gives a syntax error.

You could remove the parameter name n, then it gives:

declare s_f as function (pointer to const struct s) returning pointer to function (pointer to struct s) returning int

@KristofferC
Copy link
Contributor Author

it is used here https://github.com/dankamongmen/notcurses/blob/4f91a717d1e37df95080847e0eeb0cd6ece9cf10/include/notcurses/notcurses.h#L1373-L1374.

Gcc seems to be ok with it:

❯ cat test.h 
typedef struct s {
} s;

int (*s_f(const struct s* n))(struct s*);

❯ gcc -fsyntax-only test.h

❯

@KristofferC KristofferC changed the title Erro when generating from a certain syntax structure Error when generating from a certain syntax structure Dec 14, 2021
@Gnimuc Gnimuc added the bug label Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants