Is it possible to define a C++ class method that would compile cleanly but produce a warning message when used, in a way similar to the unimplemented C library functions? Something like:
int MyClass::frobnicate()
{
link_warning(frobnicate, "function not implemented");
return 0;
}
An __attribute__((deprecated))
or a newer [[deprecated]]
attribure has the right functionality (that's what I will use if there's no other option), but I would like to avoid telling the user that frobnicate
is deprecated when it's really just cannot be implemented due to XYZ reason.
A C code example (from glibc):
#define link_warning(symbol, msg) \
__make_section_unallocated (".gnu.warning." #symbol) \
static const char __evoke_link_warning_##symbol[] \
__attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
= msg;
The warning this macro gives looks like the following (here's an example of code using it):
/path/to/file.o: In function `symbol':
/path/to/file.c:line: warning: msg
A naive link_warning(MyClass::frobnicate, "function not implemented")
doesn't seem to work, and finding out and using decorated names seems hacky and unportable (and I'm not sure it will actually work).