Problem 342 - modification in G4strstreambuf.icc for GNU GCC 3.x compiler
Summary: modification in G4strstreambuf.icc for GNU GCC 3.x compiler
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: global/management (show other problems)
Version: 4.0
Hardware: PC Linux
: P2 normal
Assignee: Gabriele Cosmo
URL:
Depends on:
Blocks:
 
Reported: 2002-01-28 08:17 CET by harald.vogt
Modified: 2002-01-29 03:02 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description harald.vogt 2002-01-28 08:17:15 CET
The GNU GCC 3.x compiler with libstdc++ 3.x requires for geant4.4.0
a modification in the file G4strstreambuf.icc used by G4strstreambuf.hh
and located in the directory ./source/global/management/include.

Returning from overflow at least for cout,cerr
it is required that it returns ch (the input), which is '\n'
instead of zero if the buffer was flushed.
(see: http://mail.gnu.org/pipermail/help-gplusplus/2001-June/000339.html)

In ./source/global/management/include/G4strstreambuf.icc for
G4strstreambuf::overflow
one can fix it by adding after line 90 the following lines:

//  modification for gcc 3.0 and higher
//  the return value for cout, cerr overflow function has to be c
    #if !defined(__GNUC__) || defined(__STRICT_ANSI__)
      # if defined __cplusplus && __GNUC_PREREQ (3,0)
        if (this == & G4coutbuf || this == & G4cerrbuf) {
        result = c;
        }
      # endif
    # endif
//  end of modification

This modification concerns the following Geant4 code:
./source/global/management/src/G4ios.cc
./source/intercoms/src/G4UImanager.cc
./source/g3tog4/src/G3EleTable.cc
Therefore at least the granular libraries for those directories
have to be recreated after the compilation with the modification above.

Compiling with GNU GCC 2.95.3 I observed a general strange behaviour in cout
as mentioned in
http://mail.gnu.org/pipermail/bug-commoncpp/2001-January/000005.html
which does not appear now using GNU GCC 3.x .
Comment 1 Makoto.Asai 2002-01-28 09:26:59 CET
Hajime,
 Could you please look after this?
Comment 2 Gabriele Cosmo 2002-01-29 03:02:59 CET
Thank you for the information.
We introduced a temporary fix along the lines you suggest for gcc-3.X.X
(btw, the set of flags you propose are not portable). The fix will be
distributed in a public patch to release 4.0.