3 ms·
Maybe pass them in a struct?
by quickben 9y ago
Maybe pass them in a struct?
- CalChris 9y agoAs long as you give up all hope that you'll be passing values in registers.
- quotemstr 9y agoMost of the time, it doesn't matter. And if you have lots of arguments, you're going to spill anyway.
- dllthomas 9y agoIf the call doesn't cross compilation units, you still might. Or possibly with LTO, but I've less experience there. That said, it's certainly a concern worth being aware of where it's relevant.
- disconnected 9y agoThe linux kernel USB API has a few functions that take a bunch of arguments. For example: int usb_control_msg(struct usb_device * dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void * data, __u16 size, int timeout); So it is kind of hard to avoid going over the limit. What we end up doing is break each argument into one line, like this (I hope the formatting comes out all right): int res = usb_control_msg( dev, usb_sndctrlpipe(dev, 0), 0x41, ... ); It's not so much of an eye-sore.
- quickben 9y agoAhhhh I see. Nortel had that coding guideline actually. Just in their case, the first argument followed the parenthesis. The second argument (and the rest) followed the first argument column.
- dllthomas 9y agoThat's a good approach, as can be the struct. An option not mentioned yet is to give things smaller local names.