Comparing strings in C macros (for MODULE_LICENSE)

I would like to be able to ensure that I do not accidentally statically link any proprietary modules to the kernel. I was thinking about making MODULE_LICENSE("Proprietary")failure at compile time if MODULE was not defined. (or even better, failed if MODULE_LICENSE("GPL")it was not determined ...).

But I cannot find a good way to compare the lines inside the macro - who has good solutions?

+3
source share
1 answer

I do not think you can do this.

This is usually done by defining preprocessor characters and comparing their (integer) values:

#define LICENSE_PROPRIETARY 1
#define LICENSE_GPL         2
#define LICENSE_MIT         3

#define MODULE_LICENSE      LICENSE_GPL

#if MODULE_LICENSE != LICENSE_GPL
#error "Not GPL, fail fail"
#endif
+2
source

All Articles