I do not know how to do this at compile time, you might be better off using an enumeration and provide only values in this enumeration that exceed 10.
But of course, this limits you to specific values that may not be what you want.
There are other options available to you:
- Runtime error, such as an exception.
- ignore runtime, for example, an
if that exits a function for values that are not in your range.
As a last resort, you can process the source code using another executable file that checks the values passed to your function, but this will only work for calls that can be incremented to a constant argument. And, if they are persistent arguments, you will catch them at runtime during the testing phase long before your product gets a hundred feet from a client or beta tester. If your testing coverage is not down to scratch, but then this is another problem.
Otherwise, checking execution at runtime is your only option.
paxdiablo
source share