From ripley at stats.ox.ac.uk  Wed Apr 16 22:07:37 2008
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 16 Apr 2008 21:07:37 +0100 (BST)
Subject: [Rd] C++ complains abouct Rprintf signature
In-Reply-To: <22D850BC39A25742977325ADDE208E77026695633C@chiexchange02.w2k.jumptrading.com>
References: <22D850BC39A25742977325ADDE208E77026695633C@chiexchange02.w2k.jumptrading.com>
Message-ID: <alpine.LFD.1.00.0804162101370.10949@gannet.stats.ox.ac.uk>

Please see the posting guide:

   For questions about unexpected behavior or a possible bug, you should,
   at a minimum, copy and paste the output from sessionInfo() into
   your message.
...
   If you are using an old version of R and think it does not work
   properly, upgrade to the latest version and try that, before posting.
   If possible, try the current R-patched or R-devel version of R
   (see the FAQ for details), to see if the problem has already
   been addressed.

It has ....

On Wed, 16 Apr 2008, Vadim Organovich wrote:

> Dear R-devel,
>
> My g++ complains about the first argument to Rprintf being non-const char *. For example when compiling the line
>
> Rprintf("hello world\n");
>
> the following warning is emitted:
> warning: deprecated conversion from string constant to 'char*'
>
>
>
> Is there a reason for the non-const? It is curious that Rf_error, which is similar to RPrintf, is const.
>
>
>
> If there is a need to keep it non-const in C please consider using the patch below in future releases.
>
>
>
> Thanks,
>
> Vadim
>
> Patch to R-2.6.1/include/R_ext/Print.h
>
> #ifdef  __cplusplus
> extern "C" {
> #define CONST const
> #endif
> void Rprintf(CONST char *, ...);
> void REprintf(CONST char *, ...);
> void Rvprintf(const char *, va_list);
> void REvprintf(const char *, va_list);
> #ifdef  __cplusplus
> }
> #undef CONST
> #endif
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] C++ complains abouct Rprintf signature
Prof Brian Ripley