This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
warning: varargs function cannot be inline
- To: gcc-bugs at gcc dot gnu dot org
- Subject: warning: varargs function cannot be inline
- From: "Ben Sander" <ben dot sander at amd dot com>
- Date: Thu, 18 May 2000 16:50:36 -0500
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
---------------------------------------------------------------
# 1 "t.cpp"
class DbPrint {
public:
inline void myprintf(char *format,...) {};
};
DbPrint db;
main() {
db.myprintf("Hello?");
}