From murdoch.duncan at gmail.com  Tue Jun  7 16:36:54 2011
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Tue, 07 Jun 2011 10:36:54 -0400
Subject: [Rd] "warning: assignment discards qualifiers from pointer
 target type"
In-Reply-To: <20110607130854.GA4510@siouxsie>
References: <20110607130854.GA4510@siouxsie>
Message-ID: <4DEE3786.5000800@gmail.com>

On 07/06/2011 9:08 AM, oliver wrote:
> Hello,
>
> following an advice here from the list I looked into sources of other
> packages (xts) and found the TYPEOF() macro/function, which really is
> helpful.
>
> I iused the follwong code snippet:
>
>
>    switch( TYPEOF( filename_sexp ) )
>    {
>          case STRSXP: filename = CHAR( STRING_ELT(filename_sexp, 0) );
>                       break;
>
>          default:     error("filename argument must be a string");
>                       break;
>    }
>
>
> Here, filename is of type char*
> and one function opens a file with that name.
> So it is purely intended to just grab out the char* from the
> String-Expression.
>
> Am I doing something wrong here, or is it ok, but I have somehow
> to say the extracting macros/functions, that it is really intended
> to throw away information and that a warning is not necessary?

The result of calling CHAR should be a "const char *".  You are not 
allowed to touch the string it points to.

Duncan Murdoch



[Rd] "warning: assignment discards qualifiers from pointer target type"
Duncan Murdoch