Re: help on how to wrap a C macros when binding linux/spi/spidev.h

2018-03-29 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 29 March 2018 at 09:16:11 UTC, dangbinghoo wrote: On Thursday, 29 March 2018 at 09:13:27 UTC, dangbinghoo wrote: On Thursday, 29 March 2018 at 09:02:16 UTC, Nicholas Wilson wrote: On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote: [...] try [...] thanks for

Re: help on how to wrap a C macros when binding linux/spi/spidev.h

2018-03-29 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 29 March 2018 at 09:13:27 UTC, dangbinghoo wrote: On Thursday, 29 March 2018 at 09:02:16 UTC, Nicholas Wilson wrote: On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote: [...] try [...] thanks for your reply, but it will also fail, the compiler just gives me :

Re: help on how to wrap a C macros when binding linux/spi/spidev.h

2018-03-29 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 29 March 2018 at 09:02:16 UTC, Nicholas Wilson wrote: 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)

Re: help on how to wrap a C macros when binding linux/spi/spidev.h

2018-03-29 Thread Nicholas Wilson via Digitalmars-d-learn
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 *

Re: help on how to wrap a C macros when binding linux/spi/spidev.h

2018-03-29 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote: hi, I'm doing a D binding myself to , and has some problems to wrap the C macros. [...] PS: if I just _IOW!(char[])... it compiles, but does it mean it's unsafe? thanks!

help on how to wrap a C macros when binding linux/spi/spidev.h

2018-03-29 Thread dangbinghoo via Digitalmars-d-learn
hi, I'm doing a D binding myself to , and has some problems to wrap the C macros. ``` import core.sys.posix.sys.ioctl; ... /* IOCTL commands */ enum SPI_IOC_MAGIC = 'k'; /** * Orginal C macros. * * #define SPI_MSGSIZE(N) \ N)*(sizeof (struct spi_ioc_transfer))) < (1 <<