On Mon, 2010-11-01 at 20:56 +0200, Jani Monoses wrote:
Is there a list of which compilers are supported and what versions
recommeneded for building LO?
I was thinking of the feasibility of using gcc's __builtin_constant_p in
a macro to differentiate fast and not so fast paths for createFromAscii
cases to keep the code uniform but still get the optimizations, but then
figured that would not work with Visual Studio.
Well, it's always possible to hook off an ifdef of course. e.g.
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)
__builtin_constant_p magic
#else
normal stuff
#endif
My first thought was that this would be ideal to at a minimum jam into
the existing RTL_CONSTASCII_USTRINGPARAM to detect if someone used
RTL_CONSTASCII_USTRINGPARAM with something unsuitable.
e.g. the attached test.c where gcc will give a compile error on the
invalid line 13, but will be ok on the valid line 12. Unfortunately
__builtin_choose_expr isn't available for c++ so g++ always barfs on
the .cxx example.
There's definitely merit in some sort of cunning around
__builtin_constant_p
C.
#include <stdio.h>
void foo(int i)
{
fprintf(stderr, "foo is %s\n", i == 1 ? "constant" : "impossible");
}
#define RTL_CONSTASCII_USTRINGPARAM(str) (__builtin_choose_expr(__builtin_constant_p(str), 1,
(void)0))
int main(int argc, char *argv[]) {
const char *s = "ss";
foo(RTL_CONSTASCII_USTRINGPARAM("cc"));
foo(RTL_CONSTASCII_USTRINGPARAM(s));
return 0;
}
#include <stdio.h>
void foo(int i)
{
fprintf(stderr, "foo is %s\n", i == 1 ? "constant" : "impossible");
}
#define RTL_CONSTASCII_USTRINGPARAM(str) (__builtin_choose_expr(__builtin_constant_p(str), 1,
(void)0))
int main(int argc, char *argv[]) {
const char *s = "ss";
foo(RTL_CONSTASCII_USTRINGPARAM("cc"));
foo(RTL_CONSTASCII_USTRINGPARAM(s));
return 0;
}
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.