|
From: Larry D. <ldo...@re...> - 2008-04-28 20:23:48
|
On Mon, Apr 28, 2008 at 10:58:44AM -0700, Larry Doolittle wrote:
> vvp/vpi_priv.cc:118: warning: deprecated conversion from string constant
> to 'char*'
>
> I can "fix" the code to match 21st century compiler pedantry, in a
> number of ways. Please tell me if any of the following code fragments
> targeted at vpi_chk_error() meet your aesthetic needs:
>
> static char error_code[]="";
> info->code = error_code;
>
> static char *error_code=NULL;
> if (error_code == NULL) error_code=strdup("");
> info->code = error_code;
>
> info->code = strdup("");
info->code = (char *) "";
Odd, but kosher according to g++-4.3.
> The reason I suggest the second snippet (I
> normally favor the shortest possible code) is to put the pointer
> in dynamic memory, where dmalloc/electric-fence etc. can help
> diagnose problems in VPI code.
All the other vpi_* routines in vpi_priv.cc effectively do
the same thing as my newest snippet when they have to return
(char *) items derived from string literals.
- Larry
|