[Mesa-dev] [PATCH] util/anon_file: Fix build errors due to missing includes

Eduardo Lima Mitev elima at igalia.com
Fri Aug 9 11:56:23 UTC 2019


It was fixed already with c73988300f943e185a50aaba015f2f114ffcb262.

Eduardo

On 8/8/19 9:31 AM, Eduardo Lima Mitev wrote:
> Including stdlib.h and stdio.h is required in some configurations:
> 
> ../src/util/anon_file.c: In function ‘create_tmpfile_cloexec’:
> ../src/util/anon_file.c:75:9: error: implicit declaration of function ‘mkostemp’ [-Werror=implicit-function-declaration]
>     fd = mkostemp(tmpname, O_CLOEXEC);
>          ^~~~~~~~
> ../src/util/anon_file.c: In function ‘os_create_anonymous_file’:
> ../src/util/anon_file.c:126:11: error: implicit declaration of function ‘getenv’ [-Werror=implicit-function-declaration]
>     path = getenv("XDG_RUNTIME_DIR");
>            ^~~~~~
> ../src/util/anon_file.c:126:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
>     path = getenv("XDG_RUNTIME_DIR");
>          ^
> ../src/util/anon_file.c:133:7: error: implicit declaration of function ‘asprintf’ [-Werror=implicit-function-declaration]
>        asprintf(&name, "%s/mesa-shared-%s-XXXXXX", path, debug_name);
>        ^~~~~~~~
> ../src/util/anon_file.c:141:4: error: implicit declaration of function ‘free’ [-Werror=implicit-function-declaration]
>     free(name);
>     ^~~~
> ../src/util/anon_file.c:141:4: warning: incompatible implicit declaration of built-in function ‘free’
> ../src/util/anon_file.c:141:4: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
> cc1: some warnings being treated as errors
> ---
>  src/util/anon_file.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/util/anon_file.c b/src/util/anon_file.c
> index 184b8445bad..3334e793f5c 100644
> --- a/src/util/anon_file.c
> +++ b/src/util/anon_file.c
> @@ -33,6 +33,8 @@
>  #include <unistd.h>
>  #include <fcntl.h>
>  #include <errno.h>
> +#include <stdio.h>
> +#include <stdlib.h>
>  
>  #ifdef __FreeBSD__
>  #include <sys/mman.h>
> 


More information about the mesa-dev mailing list