<html><head></head><body>Hi,<br><br>You can use _Generic() if you want to match types. No need for compiler-dependent ifdef'ery.<br><br>Might be overkill here though.<br><br><div class="gmail_quote">Le 7 août 2020 07:55:35 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">OK for both. Although it would be nice to have a safety check in case <br>the underlying type changes and the alignof is not valid anymore.<br><br>May a static_assert when compiling with GCC, like<br>#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER)<br>static_assert(alignof(*addr) == alignof(atomic_uint), "type mismatch");<br>#endif<br><br><br>On 2020-08-07 6:44, Marvin Scholz wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">Using alignof not on a type but an expression is a GNU extension and<br>causes the following warning:<br><br>    warning: '_Alignof' applied to an expression is a GNU extension<hr>  src/posix/wait.c | 2 +-<br>  1 file changed, 1 insertion(+), 1 deletion(-)<br><br>diff --git a/src/posix/wait.c b/src/posix/wait.c<br>index 584cc493b1a..3fa6890193a 100644<br>--- a/src/posix/wait.c<br>+++ b/src/posix/wait.c<br>@@ -52,7 +52,7 @@ static struct wait_bucket<br>  static struct wait_bucket *wait_bucket_get(atomic_uint *addr)<br>  {<br>      uintptr_t u = (uintptr_t)addr;<br>-    size_t idx = (u / alignof (*addr)) % ARRAY_SIZE(wait_buckets);<br>+    size_t idx = (u / alignof (atomic_uint)) % ARRAY_SIZE(wait_buckets);<br>  <br>      return &wait_buckets[idx];<br>  }<br>-- <br>2.24.3 (Apple Git-128)<hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>