Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by John Salmon
Thu, 24 Dec 1992 15:30
varargs macros
Author: John Salmon
Date: Thu, 24 Dec 1992 15:30
Date: Thu, 24 Dec 1992 15:30
46 lines
2055 bytes
2055 bytes
I'm not sure if this is a bug or a misunderstanding. I am trying to
write a varargs macro 'Error', which adds __FILE__ and __LINE__
information to a printf-like argument list. It works fine, except
when the "rest" argument is empty, in which case the ##rest
consrtuction deletes too much of the preceding text. I expected the
##args construction to delete only the preceding comma, but instead,
it deletes the __LINE__ as well as the comma.
Is this the "correct" behavior? Is there a reason why the ##rest
construction should delete more than the previous comma? Is there a
workaround?
Thanks,
John Salmon Internet: johns@delilah.ccsf.caltech.edu
206-49 Caltech UUCP: johns%delilah.ccsf.caltech.edu@uunet.uu.net
Pasadena, CA 91125 USA Bitnet: johns@caltech.bitnet
(818)356-2907 delilah.ccsf.caltech.edu=[131.215.145.137]
delilah->cat junk.c
void volatile _Error(const char *, ...)
__attribute__ ((format (printf, 1, 2)));
#define Error(format, args...) \
_Error(__FILE__ "(%d):" format, __LINE__ , ##args)
main(){
Error("hello world");
Error("Hello %s", "world");
}
delilah->gcc -E junk.c
# 1 "junk.c"
void volatile _Error(const char *, ...)
__attribute__ ((format (printf, 1, 2)));
main(){
_Error("junk.c" "(%d):" "hello world") ;
_Error("junk.c" "(%d):" "Hello %s", 8 ,"world") ;
}
delilah->
--
John Salmon Internet: johns@delilah.ccsf.caltech.edu
206-49 Caltech UUCP: johns%delilah.ccsf.caltech.edu@uunet.uu.net
Pasadena, CA 91125 USA Bitnet: johns@caltech.bitnet
(818)356-2907 delilah.ccsf.caltech.edu=[131.215.145.137]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads