I have several drivers using a resource in my code, of which only one can be defined.
eg if I have the following defines: USB_HID, USB_SERIAL, USB_STORAGE.
and I want to test that only one is defined, is there a simple way to do this?
Currently I am doing it this way:
#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 more elegant way of doing this?
1 Answer