On Monday, 6 January 2025 at 07:26:02 UTC, Richard (Rikki) Andrew
Cattermole wrote:
On 06/01/2025 5:27 AM, data pulverizer wrote:
@(ldc.attributes.section("xdp_md"))
struct xdp_md {
I don't understand why you gave a type declaration a section.
Its not done on the C side.
https://github.com/libbpf/libbpf/blob/c5f22aca0f3aa855daa159b2777472b35e721804/include/uapi/linux/bpf.h#L6449
And this error would imply it too:
``[1] PTR hello_world.xdp_md* type_id=2 Invalid name``
I don't actually think it matters what I do with the struct it
still gives the same error until I remove the argument
completely. So if I just use `struct xdp_md` as in the C code it
outputs the same error, and if I use `void *` as the argument, it
outputs the same error. When I remove the argument completely I
get the error:
```d
PTR extern (C) long function(const(char)* fmt, uint fmt_size,
...) @nogc @system type_id=8 Invalid name
```
I use a cast like this `cast(BpfTracePrintk)6` for the value
because D will not allow a cast to `void*` in this case.
But all of this may not be that relevant, it looks like from the
output, these variables remain as D symbols and are not being
translated with the `--march=bpf` switch to instructions the
kernel can interpret.