Migration to ISO C++ an overview Gabriele Cosmo CERN - IT/ASD
ESTEC Geant4 WorkshopGabriele Cosmo, Migration to ISO C++2 Motivations & Goals It’s now a requirement which needs to be satisfied –More and more users are now developing software ISO/ANSI compliant –More and more compilers are now (finally) updating to support the standard –Somehow dictated also by the adoption of STL Make it fast and painless –Geant4 developers should NOT be directly involved –Avoid freezing of repository –Adopt a definitive solution Allow backward compatibility
ESTEC Geant4 WorkshopGabriele Cosmo, Migration to ISO C++3 The main source of the problem “New” I/O library headers & std namespace –stream buffers, formatting and manipulators, string streams, file streams,... Deprecation of C-style headers –,,,,,,,,... Mixed styles not allowed Requirement for us to still support old style See C++ Standard report document: pages including revisions and appendixes... FOR MORE...
ESTEC Geant4 WorkshopGabriele Cosmo, Migration to ISO C++4 Solution adopted in CLHEP Definition of ad-hoc I/O headers and use std:: namespace directly in the code –fstream.h, iomanip.h, iostream.h, strstream.h #ifndef HEP_USE_STD #include #else #include #endif HEP_USE_STD set automatically by configuration scripts at installation, where: #ifndef HEP_USE_STD #ifndef std #define std #endif
ESTEC Geant4 WorkshopGabriele Cosmo, Migration to ISO C++5 Possible solutions... 1 Define in global ad-hoc I/O headers for streams: G4iostream.h, … 2 Either one (or a combination) of the following: Properly define g4cout, g4cin, g4cerr, g4endl Define G4std 3 Modify G4 code accordingly 4 Introduction of G4_USE_STD control flag Adopt a similar strategy for replacing deprecated C-style headers from code IN ADDITION...
ESTEC Geant4 WorkshopGabriele Cosmo, Migration to ISO C++6 Strategy Evaluate impact of changes in the existing code including possible unforeseen changes required Study possible side-effects introduced by different (supported) implementations of STL on different (supported) platforms/compilers Give permission to a single individual (or dedicated group of experts) to commit changes to repository. Commit code on the HEAD after proper testing (resolve possible clashes at committal time) Gradually collect all new tags and build a reference version including the complete migration Add new (minor) code-guidelines when handling standard system headers