25 Jul
2024
25 Jul
'24
1:34 a.m.
Hi Sakamoto-san
+#define snd_pcm_is_playback(x) _Generic((x), \
int : snd_pcm_direction_is_playback, \
- unsigned int : snd_pcm_direction_is_playback, \
- unsigned char : snd_pcm_direction_is_playback, \
- unsigned short : snd_pcm_direction_is_playback, \
struct snd_pcm_substream *: snd_pcm_substream_is_playback, \
- const struct snd_pcm_substream *: snd_pcm_substream_is_playback)(x)
(snip)
In my opinion, it is not so important to distinguish some types which can be converted to integer implicitly/explicitly in the above case. The 'default' association is available in such case, like:
+#define snd_pcm_is_playback(x) _Generic((x), \
struct snd_pcm_substream *: snd_pcm_substream_is_playback, \
- const struct snd_pcm_substream *: snd_pcm_substream_is_playback, \
default: snd_pcm_direction_is_playback)(x)
The association would match [u|i][8|16|32|64] and f[32|64] types, and would not match to any type of pointers. However, it depends on your preference.
Wow ! I didn't know _Generic() can use default, and more good things is that it could handle bit-field, too!! It is perfect.
Thank you for your help !!
Best regards --- Kuninori Morimoto