Re: [uClinux-dev] [PATCH] debug: add a gcc-2 compat tweak
On Friday 22 January 2010 16:10:08 Jamie Lokier wrote: Mike Frysinger wrote: On Thursday 21 January 2010 20:21:31 Jamie Lokier wrote: Mike Frysinger wrote: GCC-2.x has a bug with empty arg expansion in macros. - fprintf(stderr, %s:%i: fmt, __func__, __LINE__, ## args); \ + fprintf(stderr, %s:%i: fmt, __func__, __LINE__ , ## args); \ Assuming it's what it looks like, it's not a GCC-2.x bug, it's the old GCC varargs behavior, which was documented and behaved like that since very old versions of GCC. i'm not really familiar with gcc-2 ... i didnt get into messing with toolchain stuff until like gcc-3.4 era. Wow. I haven't messed much with toolchain stuff since the 2.7.2 era ;-) it looks like a bug to me as gcc-3+ works fine. if you wanted to elaborate ... GCC 2.95 documentation: This is a special feature of the GNU C preprocessor: @samp{##} before a rest argument that is empty discards the preceding sequence of non-whitespace characters from the macro definition. (If another macro argument precedes, none of it is discarded.) It might be better to discard the last preprocessor token instead of the last preceding sequence of non-whitespace characters; in fact, we may someday change this feature to do so. We advise you to write the macro definition so that the preceding sequence of non-whitespace characters is just a single token, so that the meaning will not change if we change the definition of this feature. It's behaved like that since the macro varargs feature was introduced in GCC 2.2 (released June 1992), and was consciously changed to in GCC 3.0 (released June 2001). this one fails: #define debug(fmt, args...) x(fmt, moo, ## args) main(){debug(a);} these work: #define debug(fmt, args...) x(fmt, moo , ## args) main(){debug(a);} #define debug(fmt, args...) x(fmt, ## args) main(){debug(a);} The last one compiles for a surprising reason: fmt is preexpanded to ' a ' (complete with spaces), so the word-removal rule goes back as far as the comma and stops at the last space of the preexpanded fmt. thanks for the info Anyway, your patch is fine! :-) Only the commit message is misleading; this would be appropriate imho: GCC-2.x's variadic macro behaviour requires an isolated comma The behaviour of GCC before 3.0 was to remove the whole non-whitespace word prior to ## (after argument expansion), not just the comma. i'd agree, but it's already been committed -mike signature.asc Description: This is a digitally signed message part. ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
Re: [uClinux-dev] [PATCH] debug: add a gcc-2 compat tweak
Mike Frysinger wrote: On Thursday 21 January 2010 20:21:31 Jamie Lokier wrote: Mike Frysinger wrote: GCC-2.x has a bug with empty arg expansion in macros. - fprintf(stderr, %s:%i: fmt, __func__, __LINE__, ## args); \ + fprintf(stderr, %s:%i: fmt, __func__, __LINE__ , ## args); \ Assuming it's what it looks like, it's not a GCC-2.x bug, it's the old GCC varargs behavior, which was documented and behaved like that since very old versions of GCC. i'm not really familiar with gcc-2 ... i didnt get into messing with toolchain stuff until like gcc-3.4 era. Wow. I haven't messed much with toolchain stuff since the 2.7.2 era ;-) it looks like a bug to me as gcc-3+ works fine. if you wanted to elaborate ... GCC 2.95 documentation: This is a special feature of the GNU C preprocessor: @samp{##} before a rest argument that is empty discards the preceding sequence of non-whitespace characters from the macro definition. (If another macro argument precedes, none of it is discarded.) It might be better to discard the last preprocessor token instead of the last preceding sequence of non-whitespace characters; in fact, we may someday change this feature to do so. We advise you to write the macro definition so that the preceding sequence of non-whitespace characters is just a single token, so that the meaning will not change if we change the definition of this feature. It's behaved like that since the macro varargs feature was introduced in GCC 2.2 (released June 1992), and was consciously changed to in GCC 3.0 (released June 2001). this one fails: #define debug(fmt, args...) x(fmt, moo, ## args) main(){debug(a);} these work: #define debug(fmt, args...) x(fmt, moo , ## args) main(){debug(a);} #define debug(fmt, args...) x(fmt, ## args) main(){debug(a);} The last one compiles for a surprising reason: fmt is preexpanded to ' a ' (complete with spaces), so the word-removal rule goes back as far as the comma and stops at the last space of the preexpanded fmt. Anyway, your patch is fine! :-) Only the commit message is misleading; this would be appropriate imho: GCC-2.x's variadic macro behaviour requires an isolated comma The behaviour of GCC before 3.0 was to remove the whole non-whitespace word prior to ## (after argument expansion), not just the comma. ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
[uClinux-dev] [PATCH] debug: add a gcc-2 compat tweak
GCC-2.x has a bug with empty arg expansion in macros. Signed-off-by: Mike Frysinger vap...@gentoo.org --- stubs.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/stubs.h b/stubs.h index 7e5308d..615cab5 100644 --- a/stubs.h +++ b/stubs.h @@ -41,7 +41,7 @@ #define _debug(lvl, fmt, args...) \ do { \ if (lvl = DEBUG) { \ - fprintf(stderr, %s:%i: fmt, __func__, __LINE__, ## args); \ + fprintf(stderr, %s:%i: fmt, __func__, __LINE__ , ## args); \ fflush(stderr); \ } \ } while (0) -- 1.6.6 ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
Re: [uClinux-dev] [PATCH] debug: add a gcc-2 compat tweak
Mike Frysinger wrote: GCC-2.x has a bug with empty arg expansion in macros. if (lvl = DEBUG) { \ - fprintf(stderr, %s:%i: fmt, __func__, __LINE__, ## args); \ + fprintf(stderr, %s:%i: fmt, __func__, __LINE__ , ## args); \ fflush(stderr); \ Assuming it's what it looks like, it's not a GCC-2.x bug, it's the old GCC varargs behavior, which was documented and behaved like that since very old versions of GCC. You may wish to change the description if you submit it again. If GCC 2.x support is still desired, this ought to be an easy thing to grep for (comma followed by ##) and add to checkpatch.pl. -- Jamie ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
Re: [uClinux-dev] [PATCH] debug: add a gcc-2 compat tweak
Jivin Mike Frysinger lays it down ... GCC-2.x has a bug with empty arg expansion in macros. Applied with updated comment. At first I wondered which uClinux stubs.h you were patching ;-) Cheers, Davidm Signed-off-by: Mike Frysinger vap...@gentoo.org --- stubs.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/stubs.h b/stubs.h index 7e5308d..615cab5 100644 --- a/stubs.h +++ b/stubs.h @@ -41,7 +41,7 @@ #define _debug(lvl, fmt, args...) \ do { \ if (lvl = DEBUG) { \ - fprintf(stderr, %s:%i: fmt, __func__, __LINE__, ## args); \ + fprintf(stderr, %s:%i: fmt, __func__, __LINE__ , ## args); \ fflush(stderr); \ } \ } while (0) -- 1.6.6 ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev -- David McCullough, david_mccullo...@securecomputing.com, Ph:+61 734352815 McAfee - SnapGear http://www.snapgear.comhttp://www.uCdot.org ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
Re: [uClinux-dev] [PATCH] debug: add a gcc-2 compat tweak
On Thursday 21 January 2010 20:21:31 Jamie Lokier wrote: Mike Frysinger wrote: GCC-2.x has a bug with empty arg expansion in macros. - fprintf(stderr, %s:%i: fmt, __func__, __LINE__, ## args); \ + fprintf(stderr, %s:%i: fmt, __func__, __LINE__ , ## args); \ Assuming it's what it looks like, it's not a GCC-2.x bug, it's the old GCC varargs behavior, which was documented and behaved like that since very old versions of GCC. i'm not really familiar with gcc-2 ... i didnt get into messing with toolchain stuff until like gcc-3.4 era. it looks like a bug to me as gcc-3+ works fine. if you wanted to elaborate ... this one fails: #define debug(fmt, args...) x(fmt, moo, ## args) main(){debug(a);} these work: #define debug(fmt, args...) x(fmt, moo , ## args) main(){debug(a);} #define debug(fmt, args...) x(fmt, ## args) main(){debug(a);} -mike signature.asc Description: This is a digitally signed message part. ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev