Re: [PATCH v1 1/1] selftests/sgx: Fix the implicit declaration of asprintf() compiler error

From: Jarkko Sakkinen
Date: Sun May 12 2024 - 18:48:20 EST


On Fri May 10, 2024 at 11:37 PM EEST, Mirsad Todorovac wrote:
> tools/testing/selftests/sgx/main.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/testing/selftests/sgx/main.c b/tools/testing/selftests/sgx/main.c
> index 9820b3809c69..f5cb426bd797 100644
> --- a/tools/testing/selftests/sgx/main.c
> +++ b/tools/testing/selftests/sgx/main.c
> @@ -6,6 +6,9 @@
> #include <errno.h>
> #include <fcntl.h>
> #include <stdbool.h>
> +#ifndef __USE_GNU
> +#define __USE_GNU
> +#endif
> #include <stdio.h>
> #include <stdint.h>
> #include <stdlib.h>

__USE_GNU is an internal define, never use it for anything.

Use #define _GNU_SOURCE instead without ifndef/endif [1].

[1] https://man7.org/linux/man-pages/man3/asprintf.3.html

BR, Jarkko