[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/5] qemu/qarray.h: weak scalar type check in QARRAY_CREATE()
From: |
Christian Schoenebeck |
Subject: |
Re: [PATCH 2/5] qemu/qarray.h: weak scalar type check in QARRAY_CREATE() |
Date: |
Sun, 22 Aug 2021 14:16:48 +0200 |
On Sonntag, 22. August 2021 06:11:58 CEST Richard Henderson wrote:
> On 8/21/21 1:30 PM, Christian Schoenebeck wrote:
> > Unfortunately something like
> >
> > _Static_assert(typeof(a) == typeof(b), "type mismatch");
> >
> > is currently not suported by C. So for the time being at least
> > check that the size of the scalar types match at compile time.
>
> Did you try
> _Static_assert(__builtin_types_compatible_p(X, Y), "type mismatch");
>
>
> r~
Ah, you are right. I was trying it, but now as you pointed me at it again, I
realized I was just missing something. The specific use case here is like:
struct Foo {
...
} Foo;
Foo *var;
_Static_assert(__builtin_types_compatible_p(Foo, typeof(*var)),
"type mismatch");
So I was missing the typeof() keyword to deduce the scalar type from the
passed variable.
I'll send a v2.
Thanks!
Best regards,
Christian Schoenebeck
- [PATCH 0/5] introduce QArray, Christian Schoenebeck, 2021/08/21
- [PATCH 1/5] qemu/qarray.h: introduce QArray, Christian Schoenebeck, 2021/08/21
- [PATCH 2/5] qemu/qarray.h: weak scalar type check in QARRAY_CREATE(), Christian Schoenebeck, 2021/08/21
- [PATCH 3/5] 9pfs: make V9fsString usable via QArray API, Christian Schoenebeck, 2021/08/21
- [PATCH 4/5] 9pfs: make V9fsPath usable via QArray API, Christian Schoenebeck, 2021/08/21
- [PATCH 5/5] 9pfs: use QArray in v9fs_walk(), Christian Schoenebeck, 2021/08/21