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

Corrode doesn't handle varargs functions #142

Open
palfrey opened this issue Apr 12, 2017 · 4 comments
Open

Corrode doesn't handle varargs functions #142

palfrey opened this issue Apr 12, 2017 · 4 comments

Comments

@palfrey
Copy link

palfrey commented Apr 12, 2017

I was trying to convert ashuffle and got as far as https://github.com/joshkunz/ashuffle/blob/master/src/args.c#L20 before

stack exec -- corrode -c args.c -std=c99 -Wall -Wextra -pedantic -I/usr/local/Cellar/libmpdclient/2.10/include >/dev/null
("args.c": line 20): Corrode doesn't handle this yet:
    check_flags(const char * to_check, unsigned count, ...)
@palfrey
Copy link
Author

palfrey commented Apr 12, 2017

This is with corrode as of 84c6d7b

@jameysharp
Copy link
Owner

Thanks for trying Corrode! This is because Rust doesn't support defining varargs functions. I haven't been able to think of any workable translation for this yet. 🙁

@palfrey
Copy link
Author

palfrey commented May 28, 2017

So, unfortuantely the only way is to scan the function and look for uses of va_start, va_arg and va_end. If you're lucky, the va_list they're operating on never gets handed outside of the function and va_arg gets called with the same arg type every time (as happens in check_flags from my example). In that case, you could make the entire lot into an array argument of the relevant type. If not, then well you'd have to build something more complicated, but it might be worth starting from just that case as it'll get you a reasonable way along... I'd help out building such a thing if it wasn't for my not having written any Haskell for about 15 years!

@KamilaBorowska
Copy link

KamilaBorowska commented Jul 18, 2017

It's currently not possible to represent C varargs function in Rust. The problem isn't really recognizing varargs functions, but making them actually work and possible to call from C.

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

3 participants