Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index


On Thu, Oct 21, 2010 at 10:12:24AM +0100, Michael Meeks wrote:
 /* the macro OSL_LOG_PREFIX is intended to be an office internal macro
for now */
-#define OSL_LOG_PREFIX OSL_THIS_FILE ":" OSL_THIS_FUNC ":" OSL_MACRO_VALUE_TO_STRING( __LINE__ ) 
"; "
+#define OSL_LOG_PREFIX (OSL_THIS_FILE, ":", OSL_THIS_FUNC, ":", OSL_MACRO_VALUE_TO_STRING( 
__LINE__ ), "; ")

      If this code is actually going to be compiled in a lot of places, there
is probably some benefit to thinking this through carefully - pwrt.
issues of code size.

Why do you think this affects code size?

      Also; I can't see this code:

      :rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) )

      compiling with all those ',' in there - except that of course the comma
operator will be compiled in and we will get it to evaluate only to a ";
" at the end ;-) so this turns into:

#define OSL_LOG_PREFIX " ;"

      ;-) probably not what we want.

At least that last definitely won't happen, since I added parentheses
around the whole right hand side of the macro. And the code did
compile for me, but since there probably are other compilers used on
this code, I asked for more testing :)

      If these things are not string constants that we can concatenate, then
we need to find another compiler built-in that is a string constant that
we can use, I don't see another way here really. Glib has things like
this:

/* Provide a string identifying the current code position */
#if defined(__GNUC__) && (__GNUC__ < 3) && !defined(__cplusplus)
#  define G_STRLOC    __FILE__ ":" G_STRINGIFY (__LINE__) ":" __PRETTY_FUNCTION__ "()"
#else
#  define G_STRLOC    __FILE__ ":" G_STRINGIFY (__LINE__)
#endif

I don't imagine we're much interested in gcc2 nowadays, so this really
is just
        #  define G_STRLOC      __FILE__ ":" G_STRINGIFY (__LINE__)

#if defined (__GNUC__)
#  define G_STRFUNC     ((const char*) (__PRETTY_FUNCTION__))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 19901L
#  define G_STRFUNC     ((const char*) (__func__))
#else
#  define G_STRFUNC     ((const char*) ("???"))
#endif

That's perhaps a good replacement for the issue Tor mentioned in his
email on this subject. It should have a case for _MSC_VER though.

Cheers,
 Thomas

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.