[Rd] Effect of the R framework on ctype.c
Simon Urbanek
simon.urbanek at r-project.org
Mon Oct 8 17:17:23 CEST 2012
Sylvain,
I can see two possible reasons for this (both just speculative without an actual example):
a) it could be a conflict in (probably system) headers. isupper is typically a macro so I suspect what happens is that you have two definitions and depending on the sequence of includes and only the first one wins. By including/removing ctype.h you probably just change its sequence. Check the pre-processed .c files containing the isupper() for each of the two cases to see how they differ.
b) locale issues in your system. The implementation of isupper() may respect locales and R will setup the locale according to the environment, so maybe the locale is not defining isupper as you think. Maybe a) is only triggered by b) since the two versions may differ by locale.
There are other reasons one could think of (compiler bug when optimizing the isupper('A') constant) - it's hard to tell without a way to reproduce it.
Cheers,
Simon
On Oct 8, 2012, at 10:11 AM, Sylvain Loiseau wrote:
> Dear all,
>
> I'm facing a strange behavior in the the C code of a R package. This package, "rcqp", is a wrapper on an existing program that I did not write, "CWB".
>
> In this package, on a linux (ubuntu and debian) system, the code :
> printf(%d\n", isupper('A'));
> outputs :
> 0
> When compiled with the R framework (It behaves correctly when CWB is compiled as a standalone program).
>
> On mac osx, the code produce the expected output.
>
> This unexpected output is observed only in the context of CWB compiled through rcqp, only on linux (not mac osx), and only under certains circumstances, since a minimal R package produce the expected output. Even in CWB, this strange behavior is not observed in any part of the code.
>
> When observed, a work-around for this problem is to remove the include in which this very function, isupper, is defined:
> #include <ctype.h>
>
> Since the program is compiled and run correctly without this "include", isupper() seems to be also declared elsewhere or ctype to be found by another mechanism, and the problem seems be due to interactions between the R headers (?) and the include of the CWB code…
>
> Have you already observed such an effect or do you have any hint?
> Best,
> Sylvain
>
>
> -----
> Sylvain Loiseau
> sylvain.loiseau at univ-paris13.fr
>
> Université Paris 13-Nord
> Laboratoire Lexiques, Dictionnaires, Informatique
> (UMR 7187 CNRS/Université Paris 13-Nord)
> 99 avenue Jean-Baptiste Clément
> F-93410 Villetaneuse
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
More information about the R-devel
mailing list