--- imach/src/imach.c 2014/12/22 23:08:31 1.169 +++ imach/src/imach.c 2015/01/03 16:33:42 1.175 @@ -1,13 +1,35 @@ -/* $Id: imach.c,v 1.169 2014/12/22 23:08:31 brouard Exp $ +/* $Id: imach.c,v 1.175 2015/01/03 16:33:42 brouard Exp $ $State: Exp $ $Log: imach.c,v $ + Revision 1.175 2015/01/03 16:33:42 brouard + *** empty log message *** + + Revision 1.174 2015/01/03 16:15:49 brouard + Summary: Still in cross-compilation + + Revision 1.173 2015/01/03 12:06:26 brouard + Summary: trying to detect cross-compilation + + Revision 1.172 2014/12/27 12:07:47 brouard + Summary: Back from Visual Studio and Intel, options for compiling for Windows XP + + Revision 1.171 2014/12/23 13:26:59 brouard + Summary: Back from Visual C + + Still problem with utsname.h on Windows + + Revision 1.170 2014/12/23 11:17:12 brouard + Summary: Cleaning some \%% back to %% + + The escape was mandatory for a specific compiler (which one?), but too many warnings. + Revision 1.169 2014/12/22 23:08:31 brouard Summary: 0.98p Outputs some informations on compiler used, OS etc. Testing on different platforms. Revision 1.168 2014/12/22 15:17:42 brouard - Summary: udate + Summary: update Revision 1.167 2014/12/22 13:50:56 brouard Summary: Testing uname and compiler version and if compiled 32 or 64 @@ -527,13 +549,19 @@ #ifdef _WIN32 #include +#include +#include #else #include #endif #include #include -#include + +#if defined(__GNUC__) +#include /* Doesn't work on Windows */ +#endif + #include #include /* extern int errno; */ @@ -595,11 +623,11 @@ typedef struct { #define ODIRSEPARATOR '\\' #endif -/* $Id: imach.c,v 1.169 2014/12/22 23:08:31 brouard Exp $ */ +/* $Id: imach.c,v 1.175 2015/01/03 16:33:42 brouard Exp $ */ /* $State: Exp $ */ char version[]="Imach version 0.98p, December 2014,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015"; -char fullversion[]="$Revision: 1.169 $ $Date: 2014/12/22 23:08:31 $"; +char fullversion[]="$Revision: 1.175 $ $Date: 2015/01/03 16:33:42 $"; char strstart[80]; char optionfilext[10], optionfilefiname[FILENAMELENGTH]; int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ @@ -3628,7 +3656,7 @@ void varevsij(char optionfilefiname[], d /* fprintf(ficgp,"\n replot \"%s\" u 1:(($3+1.96*$4)*%6.3f) t \"95\%% interval\" w l 2 ",fileresprobmorprev,YEARM/estepm); */ /* fprintf(ficgp,"\n replot \"%s\" u 1:(($3-1.96*$4)*%6.3f) not w l 2 ",fileresprobmorprev,YEARM/estepm); */ fprintf(ficgp,"\n plot \"%s\" u 1:($3) not w l lt 1 ",subdirf(fileresprobmorprev)); - fprintf(ficgp,"\n replot \"%s\" u 1:(($3+1.96*$4)) t \"95\%% interval\" w l lt 2 ",subdirf(fileresprobmorprev)); + fprintf(ficgp,"\n replot \"%s\" u 1:(($3+1.96*$4)) t \"95%% interval\" w l lt 2 ",subdirf(fileresprobmorprev)); fprintf(ficgp,"\n replot \"%s\" u 1:(($3-1.96*$4)) not w l lt 2 ",subdirf(fileresprobmorprev)); fprintf(fichtm,"\n
File (multiple files are possible if covariates are present): %s\n",subdirf(fileresprobmorprev),subdirf(fileresprobmorprev)); fprintf(fichtm,"\n
Probability is computed over estepm=%d months.

\n", estepm,subdirf3(optionfilefiname,"varmuptjgr",digitp),digit); @@ -4226,21 +4254,21 @@ void printinggnuplot(char fileres[], cha fprintf(ficgp,"set xlabel \"Age\" \n\ set ylabel \"Probability\" \n\ set ter png small size 320, 240\n\ -plot [%.f:%.f] \"%s\" every :::%d::%d u 1:2 \"\%%lf",ageminpar,fage,subdirf2(fileres,"vpl"),k1-1,k1-1); +plot [%.f:%.f] \"%s\" every :::%d::%d u 1:2 \"%%lf",ageminpar,fage,subdirf2(fileres,"vpl"),k1-1,k1-1); for (i=1; i<= nlstate ; i ++) { - if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)"); - else fprintf(ficgp," \%%*lf (\%%*lf)"); + if (i==cpt) fprintf(ficgp," %%lf (%%lf)"); + else fprintf(ficgp," %%*lf (%%*lf)"); } - fprintf(ficgp,"\" t\"Period (stable) prevalence\" w l lt 0,\"%s\" every :::%d::%d u 1:($2+1.96*$3) \"\%%lf",subdirf2(fileres,"vpl"),k1-1,k1-1); + fprintf(ficgp,"\" t\"Period (stable) prevalence\" w l lt 0,\"%s\" every :::%d::%d u 1:($2+1.96*$3) \"%%lf",subdirf2(fileres,"vpl"),k1-1,k1-1); for (i=1; i<= nlstate ; i ++) { - if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)"); - else fprintf(ficgp," \%%*lf (\%%*lf)"); + if (i==cpt) fprintf(ficgp," %%lf (%%lf)"); + else fprintf(ficgp," %%*lf (%%*lf)"); } - fprintf(ficgp,"\" t\"95\%% CI\" w l lt 1,\"%s\" every :::%d::%d u 1:($2-1.96*$3) \"\%%lf",subdirf2(fileres,"vpl"),k1-1,k1-1); + fprintf(ficgp,"\" t\"95%% CI\" w l lt 1,\"%s\" every :::%d::%d u 1:($2-1.96*$3) \"%%lf",subdirf2(fileres,"vpl"),k1-1,k1-1); for (i=1; i<= nlstate ; i ++) { - if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)"); - else fprintf(ficgp," \%%*lf (\%%*lf)"); + if (i==cpt) fprintf(ficgp," %%lf (%%lf)"); + else fprintf(ficgp," %%*lf (%%*lf)"); } fprintf(ficgp,"\" t\"\" w l lt 1,\"%s\" every :::%d::%d u 1:($%d) t\"Observed prevalence \" w l lt 2",subdirf2(fileres,"p"),k1-1,k1-1,2+4*(cpt-1)); } @@ -4253,23 +4281,23 @@ plot [%.f:%.f] \"%s\" every :::%d::%d u for (i=1; i<= nlstate+1 ; i ++) { k=2*i; - fprintf(ficgp,"\"%s\" every :::%d::%d u 1:2 \"\%%lf",subdirf2(fileres,"t"),k1-1,k1-1); + fprintf(ficgp,"\"%s\" every :::%d::%d u 1:2 \"%%lf",subdirf2(fileres,"t"),k1-1,k1-1); for (j=1; j<= nlstate+1 ; j ++) { - if (j==i) fprintf(ficgp," \%%lf (\%%lf)"); - else fprintf(ficgp," \%%*lf (\%%*lf)"); + if (j==i) fprintf(ficgp," %%lf (%%lf)"); + else fprintf(ficgp," %%*lf (%%*lf)"); } if (i== 1) fprintf(ficgp,"\" t\"TLE\" w l ,"); else fprintf(ficgp,"\" t\"LE in state (%d)\" w l ,",i-1); - fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2-$3*2) \"\%%lf",subdirf2(fileres,"t"),k1-1,k1-1); + fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2-$3*2) \"%%lf",subdirf2(fileres,"t"),k1-1,k1-1); for (j=1; j<= nlstate+1 ; j ++) { - if (j==i) fprintf(ficgp," \%%lf (\%%lf)"); - else fprintf(ficgp," \%%*lf (\%%*lf)"); + if (j==i) fprintf(ficgp," %%lf (%%lf)"); + else fprintf(ficgp," %%*lf (%%*lf)"); } fprintf(ficgp,"\" t\"\" w l lt 0,"); - fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2+$3*2) \"\%%lf",subdirf2(fileres,"t"),k1-1,k1-1); + fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2+$3*2) \"%%lf",subdirf2(fileres,"t"),k1-1,k1-1); for (j=1; j<= nlstate+1 ; j ++) { - if (j==i) fprintf(ficgp," \%%lf (\%%lf)"); - else fprintf(ficgp," \%%*lf (\%%*lf)"); + if (j==i) fprintf(ficgp," %%lf (%%lf)"); + else fprintf(ficgp," %%*lf (%%*lf)"); } if (i== (nlstate+1)) fprintf(ficgp,"\" t\"\" w l lt 0"); else fprintf(ficgp,"\" t\"\" w l lt 0,"); @@ -5437,11 +5465,55 @@ int calandcheckages(int imx, int maxwav, return (1); } +#if defined(_MSC_VER) +/*printf("Visual C++ compiler: %s \n;", _MSC_FULL_VER);*/ +/*fprintf(ficlog, "Visual C++ compiler: %s \n;", _MSC_FULL_VER);*/ +//#include "stdafx.h" +//#include +//#include +//#include +//#include +typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); + +LPFN_ISWOW64PROCESS fnIsWow64Process; + +BOOL IsWow64() +{ + BOOL bIsWow64 = FALSE; + + //typedef BOOL (APIENTRY *LPFN_ISWOW64PROCESS) + // (HANDLE, PBOOL); + + //LPFN_ISWOW64PROCESS fnIsWow64Process; + + HMODULE module = GetModuleHandle(_T("kernel32")); + const char funcName[] = "IsWow64Process"; + fnIsWow64Process = (LPFN_ISWOW64PROCESS) + GetProcAddress(module, funcName); + + if (NULL != fnIsWow64Process) + { + if (!fnIsWow64Process(GetCurrentProcess(), + &bIsWow64)) + //throw std::exception("Unknown error"); + printf("Unknown error\n"); + } + return bIsWow64 != FALSE; +} +#endif void syscompilerinfo() { /* #include "syscompilerinfo.h"*/ - /* #include */ /* Only on gnu */ +#if defined(__GNUC__) +#include /* Only on gnu */ +#endif +#include + int cross = CROSS; + if (cross){ + printf("Cross-"); + fprintf(ficlog,"Cross-"); + } printf("Compiled with:");fprintf(ficlog,"Compiled with:"); #if defined(__clang__) printf(" Clang/LLVM");fprintf(ficlog," Clang/LLVM"); /* Clang/LLVM. ---------------------------------------------- */ @@ -5467,17 +5539,21 @@ void syscompilerinfo() #if defined(__SUNPRO_C) || defined(__SUNPRO_CC) printf(" Oracle Solaris Studio");fprintf(ficlog," Oracle Solaris Studio\n");/* Oracle Solaris Studio. ----------------------------------- */ #endif - printf(". ");fprintf(ficlog,". "); + printf(" for ");fprintf(ficlog," for "); // http://stackoverflow.com/questions/4605842/how-to-identify-platform-compiler-from-preprocessor-macros #ifdef _WIN32 // note the underscore: without it, it's not msdn official! // Windows (x64 and x86) + printf("Windows (x64 and x86) ");fprintf(ficlog,"Windows (x64 and x86) "); #elif __unix__ // all unices, not all compilers // Unix + printf("Unix ");fprintf(ficlog,"Unix "); #elif __linux__ // linux + printf("linux ");fprintf(ficlog,"linux "); #elif __APPLE__ - // Mac OS, not sure if this is covered by __posix__ and/or __unix__ though... + // Mac OS, not sure if this is covered by __posix__ and/or __unix__ though.. + printf("Mac OS ");fprintf(ficlog,"Mac OS "); #endif /* __MINGW32__ */ @@ -5489,16 +5565,16 @@ void syscompilerinfo() /* _WIN64 // Defined for applications for Win64. */ /* _M_X64 // Defined for compilations that target x64 processors. */ /* _DEBUG // Defined when you compile with /LDd, /MDd, and /MTd. */ -#include + #if UINTPTR_MAX == 0xffffffff - printf(" 32-bit."); /* 32-bit */ + printf(" 32-bit"); fprintf(ficlog," 32-bit");/* 32-bit */ #elif UINTPTR_MAX == 0xffffffffffffffff - printf(" 64-bit.");/* 64-bit */ + printf(" 64-bit"); fprintf(ficlog," 64-bit");/* 64-bit */ #else - printf(" wtf-bit."); /* wtf */ + printf(" wtf-bit"); fprintf(ficlog," wtf-bit");/* wtf */ #endif -struct utsname sysInfo; +/* struct utsname sysInfo; if (uname(&sysInfo) != -1) { printf(" %s %s %s %s %s\n",sysInfo.sysname, sysInfo.nodename, sysInfo.release, sysInfo.version, sysInfo.machine); @@ -5506,6 +5582,7 @@ struct utsname sysInfo; } else perror("uname() error"); + */ #if defined(__GNUC__) # if defined(__GNUC_PATCHLEVEL__) # define __GNUC_VERSION__ (__GNUC__ * 10000 \ @@ -5515,15 +5592,30 @@ struct utsname sysInfo; # define __GNUC_VERSION__ (__GNUC__ * 10000 \ + __GNUC_MINOR__ * 100) # endif - printf("GNU C version %d.\n", __GNUC_VERSION__); - fprintf(ficlog, "GNU C version %d.\n", __GNUC_VERSION__); + printf(" using GNU C version %d.\n", __GNUC_VERSION__); + fprintf(ficlog, " using GNU C version %d.\n", __GNUC_VERSION__); + printf("GNU libc version: %s\n", gnu_get_libc_version()); + fprintf(ficlog,"GNU libc version: %s\n", gnu_get_libc_version()); + #endif + + // void main() + // { #if defined(_MSC_VER) - printf("Visual C++ compiler: %s \n;", _MSC_FULL_VER); - fprintf(ficlog, "Visual C++ compiler: %s \n;", _MSC_FULL_VER); + if (IsWow64()){ + printf("The program (probably compile for 32bit) is running under WOW64 (64bit) emulation.\n"); + fprintf(ficlog, "The program (ie 32bit) is running under WOW64 (64bit) emulation.\n"); + } + else{ + printf("The process is not running under WOW64 (i.e probably on a 64bits windows).\n"); + frintf(ficlog,"The programm is not running under WOW64 (i.e probably on a 64bits windows).\n"); + } + // printf("\nPress Enter to continue..."); + // getchar(); + // } + #endif - /* printf("GNU libc version: %s\n", gnu_get_libc_version()); */ }