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

Compile warning: implicit declaration of function ‘asprintf’ #6

Open
lleaff opened this issue Mar 28, 2017 · 0 comments
Open

Compile warning: implicit declaration of function ‘asprintf’ #6

lleaff opened this issue Mar 28, 2017 · 0 comments

Comments

@lleaff
Copy link

lleaff commented Mar 28, 2017

$ cc --version
cc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cc -o inplace inplace.c
inplace.c: In function ‘main’:
inplace.c:206:9: warning: implicit declaration of function ‘asprintf’ [-Wimplicit-function-declaration]
     if (asprintf(&tmp_fname, "%s-XXXXXX", fname) == -1)
         ^

After a bit of googling it seems that on some systems _GNU_SOURCE needs to be defined.
Compiling with -D _GNU_SOURCE or adding the following declaration at the top of the file fixes this.:

#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
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

1 participant