Re: [PATCH 1/1] libbpf: replace typeof with __typeof__ for -std=c17 compatibility

From: Andrii Nakryiko
Date: Thu Jun 09 2022 - 14:12:04 EST


On Wed, Jun 8, 2022 at 11:28 PM James Hilliard
<james.hilliard1@xxxxxxxxx> wrote:
>
> Fixes errors like:
> error: expected specifier-qualifier-list before 'typeof'
> 14 | #define __type(name, val) typeof(val) *name
> | ^~~~~~
> ../src/core/bpf/socket_bind/socket-bind.bpf.c:25:9: note: in expansion of macro '__type'
> 25 | __type(key, __u32);
> | ^~~~~~
>
> Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>
> ---

If you follow DPDK link you gave me ([0]), you'll see that they ended up doing

#ifndef typeof
#define typeof __typeof__
#endif

It's way more localized. Let's do that.

But also I tried to build libbpf-bootstrap with -std=c17 and
immediately ran into issue with asm, so we need to do the same with
asm -> __asm__. Can you please update your patch and fix both issues?

[0] https://patches.dpdk.org/project/dpdk/patch/2601191342CEEE43887BDE71AB977258213F3012@xxxxxxxxxxxxxxxxxxxxxxxxxxxx/
[1] https://github.com/libbpf/libbpf-bootstrap


> tools/lib/bpf/bpf_core_read.h | 16 ++++++++--------
> tools/lib/bpf/bpf_helpers.h | 4 ++--
> tools/lib/bpf/bpf_tracing.h | 24 ++++++++++++------------
> tools/lib/bpf/btf.h | 4 ++--
> tools/lib/bpf/libbpf_internal.h | 6 +++---
> tools/lib/bpf/usdt.bpf.h | 6 +++---
> tools/lib/bpf/xsk.h | 12 ++++++------
> 7 files changed, 36 insertions(+), 36 deletions(-)
>

[...]