diff --git a/hist/hbook/src/THbookFile.cxx b/hist/hbook/src/THbookFile.cxx index fa86b23cc900d..d7fa9cc0a3e3c 100644 --- a/hist/hbook/src/THbookFile.cxx +++ b/hist/hbook/src/THbookFile.cxx @@ -137,6 +137,11 @@ static Int_t gLastEntry = -1; # define type_of_call # define DEFCHAR const char* # define PASSCHAR(string) string + +// As recommended in +// https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html +using fortran_charlen_t = size_t; + #else # define hlimit HLIMIT # define hldir HLDIR @@ -177,8 +182,8 @@ static Int_t gLastEntry = -1; extern "C" void type_of_call hlimit(const int&); #ifndef WIN32 extern "C" void type_of_call hropen(const int&,DEFCHAR,DEFCHAR,DEFCHAR, - const int&,const int&,const int,const int,const int); -extern "C" void type_of_call hrend(DEFCHAR,const int); + const int&,const int&,fortran_charlen_t,fortran_charlen_t,fortran_charlen_t); +extern "C" void type_of_call hrend(DEFCHAR,fortran_charlen_t); #else extern "C" void type_of_call hropen(const int&,DEFCHAR,DEFCHAR,DEFCHAR, const int&,const int&); @@ -189,7 +194,7 @@ extern "C" void type_of_call hrin(const int&,const int&,const int&); extern "C" void type_of_call hnoent(const int&,const int&); #ifndef WIN32 extern "C" void type_of_call hgive(const int&,DEFCHAR,const int&,const float&,const float&, - const int&,const float&,const float&,const int&,const int&,const int); + const int&,const float&,const float&,const int&,const int&,fortran_charlen_t); #else extern "C" void type_of_call hgive(const int&,DEFCHAR,const int&,const float&,const float&, const int&,const float&,const float&,const int&,const int&); @@ -198,8 +203,8 @@ extern "C" void type_of_call hgive(const int&,DEFCHAR,const int&,const float&,c //SUBROUTINE HGNT1(IDD,BLKNA1,VAR,IOFFST,NVAR,IDNEVT,IERROR) #ifndef WIN32 extern "C" void type_of_call hgiven(const int&,DEFCHAR,const int&,DEFCHAR, - const float&,const float&,const int,const int); -extern "C" void type_of_call hgnt1(const int&,DEFCHAR,DEFCHAR,const int&,const int&,const int&,const int&,const int,const int); + const float&,const float&,fortran_charlen_t,fortran_charlen_t); +extern "C" void type_of_call hgnt1(const int&,DEFCHAR,DEFCHAR,const int&,const int&,const int&,const int&,fortran_charlen_t,fortran_charlen_t); #else extern "C" void type_of_call hgiven(const int&,DEFCHAR,const int&,DEFCHAR, const float&,const float&); @@ -207,15 +212,15 @@ extern "C" void type_of_call hgnt1(const int&,DEFCHAR,DEFCHAR,const int&,const #endif #ifndef WIN32 -extern "C" void type_of_call hntvar2(const int&,const int&,DEFCHAR,DEFCHAR,DEFCHAR,int&,int&,int&,int&,int&,const int,const int, const int); -extern "C" void type_of_call hntvar3(const int&,const int&,DEFCHAR, const int); +extern "C" void type_of_call hntvar2(const int&,const int&,DEFCHAR,DEFCHAR,DEFCHAR,int&,int&,int&,int&,int&,fortran_charlen_t,fortran_charlen_t, fortran_charlen_t); +extern "C" void type_of_call hntvar3(const int&,const int&,DEFCHAR, fortran_charlen_t); #else extern "C" void type_of_call hntvar2(const int&,const int&,DEFCHAR,DEFCHAR,DEFCHAR,int&,int&,int&,int&,int&); extern "C" void type_of_call hntvar3(const int&,const int&,DEFCHAR); #endif #ifndef WIN32 -extern "C" void type_of_call hbnam(const int&,DEFCHAR,const int&,DEFCHAR,const int&,const int, const int); +extern "C" void type_of_call hbnam(const int&,DEFCHAR,const int&,DEFCHAR,const int&,fortran_charlen_t, fortran_charlen_t); #else extern "C" void type_of_call hbnam(const int&,DEFCHAR,const int&,DEFCHAR,const int&); #endif @@ -237,8 +242,8 @@ extern "C" void type_of_call hix(const int&,const int&,const float&); extern "C" void type_of_call hijxy(const int&,const int&,const int&,const float&,const float&); extern "C" float type_of_call hije(const int&,const int&,const int&); #ifndef WIN32 -extern "C" void type_of_call hcdir(DEFCHAR,DEFCHAR ,const int,const int); -extern "C" void type_of_call hldir(DEFCHAR,DEFCHAR ,const int,const int); +extern "C" void type_of_call hcdir(DEFCHAR,DEFCHAR ,fortran_charlen_t,fortran_charlen_t); +extern "C" void type_of_call hldir(DEFCHAR,DEFCHAR ,fortran_charlen_t,fortran_charlen_t); #else extern "C" void type_of_call hcdir(DEFCHAR,DEFCHAR); extern "C" void type_of_call hldir(DEFCHAR,DEFCHAR); diff --git a/main/src/h2root.cxx b/main/src/h2root.cxx index b374c16c2ffaf..c0ca8d5f0db44 100644 --- a/main/src/h2root.cxx +++ b/main/src/h2root.cxx @@ -131,6 +131,11 @@ void MAIN__() {} # define type_of_call # define DEFCHAR const char* # define PASSCHAR(string) string + +// As recommended in +// https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html +using fortran_charlen_t = size_t; + #else # define hlimit HLIMIT # define hropen HROPEN @@ -169,7 +174,7 @@ void MAIN__() {} extern "C" void type_of_call hlimit(const int&); #ifndef WIN32 extern "C" void type_of_call hropen(const int&,DEFCHAR,DEFCHAR,DEFCHAR, - const int&,const int&,const int,const int,const int); + const int&,const int&,fortran_charlen_t,fortran_charlen_t,fortran_charlen_t); #else extern "C" void type_of_call hropen(const int&,DEFCHAR,DEFCHAR,DEFCHAR, const int&,const int&); @@ -179,7 +184,7 @@ extern "C" void type_of_call hrin(const int&,const int&,const int&); extern "C" void type_of_call hnoent(const int&,const int&); #ifndef WIN32 extern "C" void type_of_call hgive(const int&,DEFCHAR,const int&,const float&,const float&, - const int&,const float&,const float&,const int&,const int&,const int); + const int&,const float&,const float&,const int&,const int&,fortran_charlen_t); #else extern "C" void type_of_call hgive(const int&,DEFCHAR,const int&,const float&,const float&, const int&,const float&,const float&,const int&,const int&); @@ -187,29 +192,37 @@ extern "C" void type_of_call hgive(const int&,DEFCHAR,const int&,const float&,c #ifndef WIN32 extern "C" void type_of_call hgiven(const int&,DEFCHAR,const int&,DEFCHAR, - const float&,const float&,const int,const int); + const float&,const float&,fortran_charlen_t,fortran_charlen_t); #else extern "C" void type_of_call hgiven(const int&,DEFCHAR,const int&,DEFCHAR, const float&,const float&); #endif #ifndef WIN32 -extern "C" void type_of_call hntvar2(const int&,const int&,DEFCHAR,DEFCHAR,DEFCHAR,int&,int&,int&,int&,int&,const int,const int, const int); +extern "C" void type_of_call hntvar2(const int&,const int&,DEFCHAR,DEFCHAR,DEFCHAR,int&,int&,int&,int&,int&,fortran_charlen_t,fortran_charlen_t,fortran_charlen_t); #else extern "C" void type_of_call hntvar2(const int&,const int&,DEFCHAR,DEFCHAR,DEFCHAR,int&,int&,int&,int&,int&); #endif #ifndef WIN32 -extern "C" void type_of_call hbnam(const int&,DEFCHAR,const int&,DEFCHAR,const int&,const int, const int); +extern "C" void type_of_call hbnam(const int&,DEFCHAR,const int&,DEFCHAR,const int&,fortran_charlen_t,fortran_charlen_t); #else extern "C" void type_of_call hbnam(const int&,DEFCHAR,const int&,DEFCHAR,const int&); #endif extern "C" void type_of_call hprntu(const int&); -extern "C" void type_of_call hgnpar(const int&,const char *,const int); +#ifndef WIN32 +extern "C" void type_of_call hgnpar(const int&,DEFCHAR,fortran_charlen_t); +#else +extern "C" void type_of_call hgnpar(const int&,DEFCHAR); +#endif extern "C" void type_of_call hgnf(const int&,const int&,const float&,const int&); extern "C" void type_of_call hgnt(const int&,const int&,const int&); -extern "C" void type_of_call rzink(const int&,const int&,const char *,const int); +#ifndef WIN32 +extern "C" void type_of_call rzink(const int&,const int&,DEFCHAR,fortran_charlen_t); +#else +extern "C" void type_of_call rzink(const int&,const int&,DEFCHAR); +#endif extern "C" void type_of_call hdcofl(); extern "C" void type_of_call hmaxim(const int&,const float&); extern "C" void type_of_call hminim(const int&,const float&); @@ -232,14 +245,14 @@ extern "C" double type_of_call hije(const int&,const int&,const int&); #endif #ifndef WIN32 -extern "C" void type_of_call hcdir(DEFCHAR,DEFCHAR ,const int,const int); +extern "C" void type_of_call hcdir(DEFCHAR,DEFCHAR ,fortran_charlen_t,fortran_charlen_t); #else extern "C" void type_of_call hcdir(DEFCHAR,DEFCHAR); #endif extern "C" void type_of_call zitoh(const int&,const int&,const int&); #ifndef WIN32 -extern "C" void type_of_call uhtoc(const int&,const int&,DEFCHAR,int&,const int); +extern "C" void type_of_call uhtoc(const int&,const int&,DEFCHAR,int&,fortran_charlen_t); #else extern "C" void type_of_call uhtoc(const int&,const int&,DEFCHAR,int&); #endif @@ -312,7 +325,11 @@ int main(int argc, char **argv) int lun = 10; #ifndef WIN32 - hropen(lun,PASSCHAR("example"),PASSCHAR(file_in),PASSCHAR("px"),record_size,ier,7,strlen(file_in),2); + // Reminder: Argument passing convention is that string lengths go as hidden arguments + // at the end of the argument list. + constexpr auto chdir = "example"; + constexpr auto opt = "px"; + hropen(lun, chdir, file_in, opt, record_size, ier, strlen(chdir), strlen(file_in), strlen(opt)); #else hropen(lun,PASSCHAR("example"),PASSCHAR(file_in),PASSCHAR("px"),record_size,ier); #endif