Re: [Rd] Effect of the R framework on ctype.c

From: Simon Urbanek <>
Date: Mon, 08 Oct 2012 11:17:23 -0400


I can see two possible reasons for this (both just speculative without an actual example):

  1. 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.
  2. 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.


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
> Université Paris 13-Nord
> Laboratoire Lexiques, Dictionnaires, Informatique
> (UMR 7187 CNRS/Université Paris 13-Nord)
> 99 avenue Jean-Baptiste Clément
> F-93410 Villetaneuse
> ______________________________________________
> mailing list
> mailing list Received on Mon 08 Oct 2012 - 15:19:36 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 09 Oct 2012 - 16:10:54 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive