warning: varargs function cannot be inline
Ben Sander
ben.sander@amd.com
Thu May 18 14:50:00 GMT 2000
G++ does not currently allow functions with variable arguments to
be inlined, even in the case where the function is empty. Consider:
# 1 "t.cpp"
class DbPrint {
public:
inline void myprintf(char *format,...) {};
};
DbPrint db;
main() {
db.myprintf("Hello?");
}
During the debug phase of the project, DbPrint::myprintf is a real
functions that actually checks some status and potentially prints
a message. However, for higher-performance we would like to
change myprintf to an empty function, then have the compiler inline
and remove the call to myprintf. Essentially, this allows us to leave
the debug code in the source code but have it all be removed by
the compiler depending on a #define.
We are using g++ 2.95.2 on Solaris, which currently does not inline the empty
myprintf function because it contains a variable argument list:
> g++ -O3 -Winline t.ii
t.cpp: In method `void DbPrint::myprintf(char *, ...)':
t.cpp:3: warning: varargs function cannot be inline
t.cpp: In function `int main()':
t.cpp:3: warning: can't inline call to `void DbPrint::myprintf(char *, ...)'
t.cpp:10: warning: called from here
My request is that the inliner be smart enough to always inline empty
functions, even in the case where the function takes a variable number
of arguments.
thanks,
-Ben Sander
---------------------------------------------------------------
Ben Sander ben.sander@amd.com
Texas Microprocessor Division Phone: (512) 602-2753
Advanced Micro Devices Fax: (512) 602-6970
---------------------------------------------------------------
More information about the Gcc-bugs
mailing list