Problem 400

Summary: Incompatible typecast to socklen_t
Product: Geant4 Reporter: savage
Component: interfaces/GAGAssignee: yoshidah
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 4.1   
Hardware: PC   
OS: Linux   

Description savage 2002-08-15 13:19:41 CEST
Compiling of the file G4UIGainServer.cc failed due to:

src/G4UIGainServer.cc: In method `void G4UIGainServer::WaitingConnection ()':
src/G4UIGainServer.cc:407: cannot convert `int *' to `socklen_t *' for argument
`3' to `accept (int, sockaddr *, socklen_t *)'


The offending line of code reads:

if((socketD[i] = accept(socketD[0], (struct sockaddr *)&caddr,(int *)&len))<0){


While searching through the net, I found this problem arises because the typedef
of socklen_t is platform dependent (int on some systems, unsigned int on
others).  In my case, compilation was achieved by switching the above line to:

if((socketD[i] = accept(socketD[0], (struct sockaddr *)&caddr,(unsigned int
*)&len))<0){
Comment 1 yoshidah 2002-08-29 01:51:59 CEST
This is a famous "philosophical" issue. Linux requires unsigned int for this
argument, while other Unixen are sticked to the legacy signed int.

We have decided to offer the codes accepted to the legacy Unixen, while
Linux may warn this problem, knowing that gcc-2.95.x warns this, while gcc-3.x
(including 2.96.x) report a compile error.

For the temporary patch, please change (int *) to (socklen=t *) at the line 401
of the G4UIGainServer.cc.

We are reluctant to introduce a conditional compilation, but in the near future,
we have to do so.

Any better solution is welcome.

Hajime Yoshida
Comment 2 Gabriele Cosmo 2004-02-18 08:17:59 CET
With the more recent compilers the problem looks now resolved,
so we now can close this.