I have several drivers that use a resource in my code, of which only one can be determined. for example, if I have the following definitions: USB_HID, USB_SERIAL, USB_STORAGE. and I want to check that only one of them is defined, is there an easy way to do this? I am currently doing it like this:
#ifdef USB_HID
#ifdef USB_INUSE
#error "Can only have one USB device"
#else
#define USB_INUSE
#endif
#endif
#ifdef USB_SERIAL
#ifdef USB_INUSE
#error "Can only have one USB device"
#else
#define USB_INUSE
#endif
#endif
... with one of these blocks for each USB_XXX driver. Is there a more elegant way to do this?
source
share