NetBSD-Users archive

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

Re: Porting an OSS application



Hi Christos,

On 05/04/12 01:42, Christos Zoulas wrote:
In article<20120503223052.1bef66c8.dieter.NetBSD%pandora.be@localhost>,
dieter roelants<dieter.NetBSD%pandora.be@localhost>  wrote:

soundcard.h contains:

#include<sys/ioctl.h>
#define ioctl(x,y,z) _oss_ioctl(x,y,z)
perhaps defining it this way is better:

#define ioctl(x, y, ...) _oss_ioctl(x, y, __VA_ARGS__)
I think this is still not perfect, since it does not allow the variadic argument to be empty.
I tried to use the gcc extension [1]

#define ioctl(x, y, ...) _oss_ioctl(x, y, ##__VA_ARGS__)

However, this way, my code will complain with:

OSS.m:111:3: error: too few arguments to function '_oss_ioctl'
/usr/include/sys/soundcard.h:311:5: note: declared here

line 311 says:
int _oss_ioctl(int fd, unsigned long com, void *argp);

so it is expecting directly the arg.pointer, not the argument list. I think this is wrong, since ioctl has the arglist instead:
     int
     ioctl(int d, unsigned long request, ...);

it looks there is a mismatch and the Macro was hiding this?

Riccardo

PS: [1] http://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html


Home | Main Index | Thread Index | Old Index