I wonder if some C/C++ compilers implementing something similar to Pawn's stock keyword.
In Pawn, you can declare a function like that:
stock xfunc(a, b)
{
[...] // Bla bla
}
The stock keyword tells the compiler to simply not include the function in the compiled binary if it's not called somewhere in the code. This makes the function facultative so to speak, and it won't increase the binary size if its not used.
I would find it useful to have something like this in C/C++ because I want to include some functions I will not immediately use in the first iterations of my program/code. Of course, some people might tell me there's other ways to do this like using preprocessor macros, etc etc. I'm not asking for another way, I want something that permits me to make use of those functions later without having to uncomment them, change a macro to make them get compiled, etc (i.e. seamlessly). BUT... without compiling them and thus increasing my executable size when I don't use them!
A handy feature I would say. Thanks!
P.S. If the answer is "it's not included in the language standards", are there any compilers that do it with specific pragmas, unofficial keywords, etc.?
EDIT: Should I mention, I'm mostly interested into this feature for virtual function. I'm aware function level linking exists for standard functions, but what about virtual ones? I think normally, if im not mistaken, virtual funcs get compiled even if not used to maintain class layout compatibe with a class prototype? Could you confirm? Thanks