help on how to wrap a C macros when binding linux/spi/spidev.h
Nicholas Wilson
iamthewilsonator at hotmail.com
Thu Mar 29 09:02:16 UTC 2018
On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote:
> * #define SPI_MSGSIZE(N) \
> ((((N)*(sizeof (struct spi_ioc_transfer))) < (1 <<
> _IOC_SIZEBITS)) \
> ? ((N)*(sizeof (struct spi_ioc_transfer))) : 0)
> */
> extern (D) size_t SPI_MSGSIZE(size_t N)
> {
> return ((N * (spi_ioc_transfer.sizeof)) < (1 <<
> _IOC_SIZEBITS)) ? (N * (spi_ioc_transfer.sizeof)) : 0;
> }
>
> /* #define SPI_IOC_MESSAGE(N) _IOW(SPI_IOC_MAGIC, 0,
> char[SPI_MSGSIZE(N)]) */
> extern (D) auto SPI_IOC_MESSAGE(size_t N)
> {
> size_t n = SPI_MSGSIZE(N);
> return _IOW!(char[static n])(SPI_IOC_MAGIC, 0);
> //mixin("return _IOW!(char[n])(SPI_IOC_MAGIC, 0);");
> }
> ```
>
try
> extern (D) auto SPI_IOC_MESSAGE(size_t N)()
> {
> enum n = SPI_MSGSIZE(N);
> return _IOW!(char[n])(SPI_IOC_MAGIC, 0);
> //mixin("return _IOW!(char[n])(SPI_IOC_MAGIC, 0);");
> }
More information about the Digitalmars-d-learn
mailing list