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

implicit declaration of function 'arc4random' is invalid in C99 #10709

Closed
Beuc opened this issue Mar 17, 2020 · 2 comments
Closed

implicit declaration of function 'arc4random' is invalid in C99 #10709

Beuc opened this issue Mar 17, 2020 · 2 comments

Comments

@Beuc
Copy link
Contributor

@Beuc Beuc commented Mar 17, 2020

Hi,

When compiling libzip 1.6.1 with Emscripten I got:

libzip-1.6.1/lib/zip_random_unix.c:48:5: error: implicit declaration of function 'arc4random_buf' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    arc4random_buf(buffer, length);
    ^
libzip-1.6.1/lib/zip_random_unix.c:56:12: error: implicit declaration of function 'arc4random' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    return arc4random();
           ^
2 errors generated.

These functions are provided by Emscripten:

// For compatibility, call to rand() when code requests arc4random(), although this is *not* at all

but don't seem to be declared.
If we're going for *bsd compatibility here, I believe function prototypes needs to be added to stdlib.h.

@sbc100

This comment has been minimized.

Copy link
Collaborator

@sbc100 sbc100 commented Mar 17, 2020

I don't think we should be aiming for such compatibility.

It looks like it was added in a5c78a5, but without any explanation or tests, then has remained around since then including a test being added but without any rational that I can find. Can we just remove this? Its not present of any windows or linux desktop. @azakai ?

sbc100 added a commit that referenced this issue Mar 17, 2020
This was added back in 2013 but the rational seems to be lost to
that sands of time.

See:  a5c78a5

I see no reason to maintain compatibility with this BSD-only function.

Fixes: #10709
@Beuc

This comment has been minimized.

Copy link
Contributor Author

@Beuc Beuc commented Mar 18, 2020

Thanks!

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

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.