Is there any way to implement a custom type qualifier (similar to const)? I would like to only allow function calls to functions that are of the right qualification, within functions with the same qualification.
Let's say I would have:
void allowedFunction();
void disallowedFunction();
//Only allowed to call allowed functions.
void foo()
{
allowedFunction();
disallowedFunction(); //Cause compile time error
}
//Is allowed to call any function it wants.
void bar()
{
allowedFunction();
disallowedFunction(); //No error
}
The reason I would like to do this is because I want to make sure that functions called on a specific thread only call realtime-safe functions. Since many applications require hard realtime-safe threads, having some way to detect locks at compile-time would guarantee us that many hard to detect runtime errors cannot happen.