Andrew Finley
2008-Apr-03 14:48 UTC
[Rd] g++ 4.3 warning: deprecated conversion from string constant to ‘char*’
Hello,
I've noticed that with g++ 4.3 I get the following "warning: deprecated
conversion from string constant to ?char*?" when I call e.g.,
Rprintf("Hello world"); or when I try to define a const char e.g.,
char
lower = 'L';
I am wrapping the c++ code in extern "C" {}. This seems to be
something
new with g++ 4.3, because the same code compiled without warnings with
previous versions.
Has anyone else had theses warnings? Any fixes?
I have included some example output below. Each warning corresponds to
an Rprintf call.
andy at friend:~/Rdevel/tmp$ R CMD SHLIB splmDIC.cpp covmodel.cpp util.cpp
g++-4.3 -I/usr/local/lib/R/include -I/usr/local/lib/R/include
-I/usr/local/include -fpic -g -O2 -c splmDIC.cpp -o splmDIC.o
splmDIC.cpp: In function ?SEXPREC* splmDIC(SEXPREC*, SEXPREC*, SEXPREC*,
SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*,
SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*,
SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*)?:
splmDIC.cpp:163: warning: deprecated conversion from string constant to
?char*?
splmDIC.cpp:164: warning: deprecated conversion from string constant to
?char*?
splmDIC.cpp:165: warning: deprecated conversion from string constant to
?char*?
splmDIC.cpp:430: warning: deprecated conversion from string constant to
?char*?
splmDIC.cpp:431: warning: deprecated conversion from string constant to
?char*?
g++-4.3 -shared -L/usr/local/lib -o splmDIC.so splmDIC.o covmodel.o
util.o -L/usr/local/lib/R/lib -lRlapack -L/usr/local/lib/R/lib -lRblas
-L/usr/lib/gcc/i486-linux-gnu/3.4.6 -lg2c -lm -lgcc_s
Thanks for your time.
Kind regards-
Andy
--
Andrew Finley, PhD
Natural Resources Building
Michigan State University
East Lansing, MI 48824-1222
Phone: 517-432-7219
Fax: 517-432-1143
web: http://blue.for.msu.edu
Prof Brian Ripley
2008-Apr-03 16:33 UTC
[Rd] g++ 4.3 warning: deprecated conversion from string constant to ‘char*’
SunStudio has given these warnings for a long time, and we added const to several R declarations (most recently Rprintf) to suppress them. And yes, we noticed that gcc 4.3.0 gave them too. So what version of R is this? I don't think 2.7.0 alpha does this. And I suggest you don't mix 'g++-4.3' with R compiled under gcc 3.4.6 and gfortran -- some of the argument passing is incompatible. On Thu, 3 Apr 2008, Andrew Finley wrote:> Hello, > I've noticed that with g++ 4.3 I get the following "warning: deprecated > conversion from string constant to ?char*?" when I call e.g., > Rprintf("Hello world"); or when I try to define a const char e.g., char > lower = 'L'; > > I am wrapping the c++ code in extern "C" {}. This seems to be something > new with g++ 4.3, because the same code compiled without warnings with > previous versions. > > Has anyone else had theses warnings? Any fixes? > > I have included some example output below. Each warning corresponds to > an Rprintf call. > > > andy at friend:~/Rdevel/tmp$ R CMD SHLIB splmDIC.cpp covmodel.cpp util.cpp > g++-4.3 -I/usr/local/lib/R/include -I/usr/local/lib/R/include > -I/usr/local/include -fpic -g -O2 -c splmDIC.cpp -o splmDIC.o > splmDIC.cpp: In function ?SEXPREC* splmDIC(SEXPREC*, SEXPREC*, SEXPREC*, > SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, > SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, > SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*)?: > splmDIC.cpp:163: warning: deprecated conversion from string constant to > ?char*? > splmDIC.cpp:164: warning: deprecated conversion from string constant to > ?char*? > splmDIC.cpp:165: warning: deprecated conversion from string constant to > ?char*? > splmDIC.cpp:430: warning: deprecated conversion from string constant to > ?char*? > splmDIC.cpp:431: warning: deprecated conversion from string constant to > ?char*? > g++-4.3 -shared -L/usr/local/lib -o splmDIC.so splmDIC.o covmodel.o > util.o -L/usr/local/lib/R/lib -lRlapack -L/usr/local/lib/R/lib -lRblas > -L/usr/lib/gcc/i486-linux-gnu/3.4.6 -lg2c -lm -lgcc_s > > > Thanks for your time. > Kind regards- > Andy > > > > -- > Andrew Finley, PhD > Natural Resources Building > Michigan State University > East Lansing, MI 48824-1222 > Phone: 517-432-7219 > Fax: 517-432-1143 > web: http://blue.for.msu.edu > > ______________________________________________ > 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
Kurt Hornik
2008-Apr-03 16:33 UTC
[Rd] g++ 4.3 warning: deprecated conversion from string constant to ‘char*’ 3DIn-Reply-To: <47F4EE2E.6090407@msu.edu>
>>>>> Andrew Finley writes:> Hello, > I've noticed that with g++ 4.3 I get the following "warning: deprecated > conversion from string constant to ?char*?" when I call e.g., > Rprintf("Hello world"); or when I try to define a const char e.g., char > lower = 'L';> I am wrapping the c++ code in extern "C" {}. This seems to be something > new with g++ 4.3, because the same code compiled without warnings with > previous versions.> Has anyone else had theses warnings? Any fixes?Does this persist in a current version of 2.7.0 alpha? Brian recently changed R_ext/Print.h to -void Rprintf(char *, ...); -void REprintf(char *, ...); +void Rprintf(const char *, ...); +void REprintf(const char *, ...); to deal with this issue. Best -k> I have included some example output below. Each warning corresponds to > an Rprintf call.> andy at friend:~/Rdevel/tmp$ R CMD SHLIB splmDIC.cpp covmodel.cpp util.cpp > g++-4.3 -I/usr/local/lib/R/include -I/usr/local/lib/R/include > -I/usr/local/include -fpic -g -O2 -c splmDIC.cpp -o splmDIC.o > splmDIC.cpp: In function ?SEXPREC* splmDIC(SEXPREC*, SEXPREC*, SEXPREC*, > SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, > SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, > SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*)?: > splmDIC.cpp:163: warning: deprecated conversion from string constant to > ?char*? > splmDIC.cpp:164: warning: deprecated conversion from string constant to > ?char*? > splmDIC.cpp:165: warning: deprecated conversion from string constant to > ?char*? > splmDIC.cpp:430: warning: deprecated conversion from string constant to > ?char*? > splmDIC.cpp:431: warning: deprecated conversion from string constant to > ?char*? > g++-4.3 -shared -L/usr/local/lib -o splmDIC.so splmDIC.o covmodel.o > util.o -L/usr/local/lib/R/lib -lRlapack -L/usr/local/lib/R/lib -lRblas > -L/usr/lib/gcc/i486-linux-gnu/3.4.6 -lg2c -lm -lgcc_s> Thanks for your time. > Kind regards- > Andy> -- > Andrew Finley, PhD > Natural Resources Building > Michigan State University > East Lansing, MI 48824-1222 > Phone: 517-432-7219 > Fax: 517-432-1143 > web: http://blue.for.msu.edu> ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel