/*******************************************************************************/ /* */ /* This code demonstrates how to have one code that is */ /* [a] compilable using eg. g++ and [b] executable as a root macro */ /* */ /* For [a] type: root -b "macro_cprogram_unifier.C (123456)" */ /* */ /* For [b] type: g++ macro_cprogram_unifier.C `root-config --cflags --libs` */ /* ./a.out 123456 */ /* */ /*******************************************************************************/ #if defined __CINT__ || defined __CLING__ int macro_cprogram_unifier (int InputValue = 123) { cout << "\n Hello, I am being interpretted." << endl; #else #include "TMath.h" #include #include using namespace std; int main (int argc, char* argv[]) { cout << "\n Hello, I was compiled." << endl; int InputValue = (argc > 1) ? atoi (argv[1]) : 123; #endif cout << "\n Okay, and this is the common portion of code." << endl; cout << " TMath::Pi() = " << setprecision (18) << TMath::Pi() << endl; cout << " Input value (default: 123) = " << InputValue << "\n\n"; return 0; }