If your header has a namespace, you could use the [[deprecated]]
on it I guess? But this doesn't work on anonymous namespaces. And the user has to use something from the headspace for it to work.
If you can put the header in a namespace, then all you have to do is have a using
statement that will trigger the warning. This could be also a good idea to isolate those functions, and making sure users have more difficulty using them if that's an objective.
namespace [[deprecated]] N {
struct S {
};
}
using N::S;
But if you can't afford the namespace, depending on the number of elements, you probably don't want to use a using
on all of them.
Maybe that could be a case for legitimately having a using namespace N;
, but I'm not sure.
After some research, you could use #pragma message "Message"
to possibly also achieve what you seem to be wanting. See this answer
godbolt