Re: [PATCH 001/112] ALSA: add snd_pcm_is_playback/capture() macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux