Message: strdup's not defined Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Warning strdup's not defined 

Forum: Installation and Configuration
Date: 29 Apr, 2010
From: Mathieu Trocmé <Mathieu Trocmé>

Hi there, 

'strdup' (http://www.opengroup.org/onlinepubs/009695399/functions/strdup.html) 
is used on line 501 of $G4INSTALL/source/visualization/OpenGL/G4OpenGLViewer.cc (>= g4.9.3). 
Unfortunately, it is not recognized on every platform (at least on cygwin). 
So I had to recode it taking inspiration from 
http://www.developpez.net/forums/d442003/c-cpp/c/debuter/strdup-ca-marche/

> G4OpenGLViewer.hh: 
char* _strdup(char const *s) ;

> G4OpenGLViewer.cc: 
char* G4OpenGLViewer::_strdup(char const *s)
{
 char *pc = NULL ;
 if (s != NULL) {
   pc = (char*) malloc( (strlen(s) + 1) * sizeof *pc ) ;
   if (pc != NULL) { strcpy (pc,s) ; }
 }
 return pc ;
}

Maybe should it be safer to code it this way...
Its location may be elsewhere though (G4ios.cc?)

Cheers, 
M

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: strdup's not defined   (John Allison - 30 Apr, 2010)
1 None: Re: strdup's not defined   (Tom Roberts - 30 Apr, 2010)
(_ None: Re: strdup's not defined   (Mathieu Trocmé - 30 Apr, 2010)
(_ None: Re: strdup's not defined   (Tom Roberts - 30 Apr, 2010)
(_ None: Re: strdup's not defined   (Colin Paul Gloster - 30 Apr, 2010)
(_ None: Re: strdup's not defined   (Mathieu Trocmé - 30 Apr, 2010)
2 None: Re: strdup's not defined   (Makoto Asai - 30 Apr, 2010)
1 None: Re: strdup's not defined   (Mathieu Trocmé - 30 Apr, 2010)
 Add Message Add Message
to: "strdup's not defined"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]