You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.7 KiB

  1. //=============================================================================
  2. // File : utilities.h
  3. // Created : mar jun 19 13:18:14 CEST 2001
  4. // Author : Antoine YESSAYAN, Paul RASCLE, EDF
  5. // Project : SALOME
  6. // Copyright : EDF 2001
  7. // $Header$
  8. //=============================================================================
  9. /* --- Definition macros file to print information if _DEBUG_ is defined --- */
  10. # ifndef UTILITIES_H
  11. # define UTILITIES_H
  12. # include <stdlib.h>
  13. //# include <iostream> ok for gcc3.01
  14. # include <iostream>
  15. /* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */
  16. # define HEREWEARE cout<<flush ; cerr << __FILE__ << " [" << __LINE__ << "] : " << flush ;
  17. # define INFOS(chain) {HEREWEARE ; cerr << chain << endl ;}
  18. # define PYSCRIPT(chain) {cout<<flush ; cerr << "---PYSCRIPT--- " << chain << endl ;}
  19. /* --- To print date and time of compilation of current source on stdout --- */
  20. # if defined ( __GNUC__ )
  21. # define COMPILER "g++" ;
  22. # elif defined ( __sun )
  23. # define COMPILER "CC" ;
  24. # elif defined ( __KCC )
  25. # define COMPILER "KCC" ;
  26. # elif defined ( __PGI )
  27. # define COMPILER "pgCC" ;
  28. # else
  29. # define COMPILER "undefined" ;
  30. # endif
  31. # ifdef INFOS_COMPILATION
  32. # error INFOS_COMPILATION already defined
  33. # endif
  34. # define INFOS_COMPILATION {\
  35. cerr << flush;\
  36. cout << __FILE__ ;\
  37. cout << " [" << __LINE__ << "] : " ;\
  38. cout << "COMPILED with " << COMPILER ;\
  39. cout << ", " << __DATE__ ; \
  40. cout << " at " << __TIME__ << endl ;\
  41. cout << "\n\n" ;\
  42. cout << flush ;\
  43. }
  44. # ifdef _DEBUG_
  45. /* --- the following MACROS are useful at debug time --- */
  46. # define HERE cout<<flush ; cerr << "- Trace " << __FILE__ << " [" << __LINE__ << "] : " << flush ;
  47. # define SCRUTE(var) HERE ; cerr << #var << "=" << var << endl ;
  48. # define MESSAGE(chain) {HERE ; cerr << chain << endl ;}
  49. # define INTERRUPTION(code) HERE ; cerr << "INTERRUPTION return code= " << code << endl ; exit(code) ;
  50. # ifndef ASSERT
  51. # define ASSERT(condition) if (!(condition)){ HERE ; cerr << "CONDITION " << #condition << " NOT VERIFIED"<< endl ; INTERRUPTION(1) ;}
  52. # endif /* ASSERT */
  53. #define REPERE cout<<flush ; cerr << " --------------" << endl << flush ;
  54. #define BEGIN_OF(chain) {REPERE ; HERE ; cerr << "Begin of: " << chain << endl ; REPERE ; }
  55. #define END_OF(chain) {REPERE ; HERE ; cerr << "Normal end of: " << chain << endl ; REPERE ; }
  56. # else /* ifdef _DEBUG_*/
  57. # define HERE
  58. # define SCRUTE(var)
  59. # define MESSAGE(chain)
  60. # define INTERRUPTION(code)
  61. # ifndef ASSERT
  62. # define ASSERT(condition)
  63. # endif /* ASSERT */
  64. #define REPERE
  65. #define BEGIN_OF(chain)
  66. #define END_OF(chain)
  67. # endif /* ifdef _DEBUG_*/
  68. # endif /* ifndef UTILITIES_H */