]> henry.ined.fr Git - .git/commitdiff
Summary: Testing uname and compiler version and if compiled 32 or 64
authorN. Brouard <brouard@ined.fr>
Mon, 22 Dec 2014 13:50:56 +0000 (13:50 +0000)
committerN. Brouard <brouard@ined.fr>
Mon, 22 Dec 2014 13:50:56 +0000 (13:50 +0000)
Testing on Linux 64

src/imach.c

index c3cc6d61d01ca6d192cde2b560839a1f3aade471..dd297e6586832e5e2f236707f4be8af03a6c5841 100644 (file)
@@ -1,6 +1,9 @@
 /* $Id$
   $State$
   $Log$
+  Revision 1.166  2014/12/22 11:40:47  brouard
+  *** empty log message ***
+
   Revision 1.165  2014/12/16 11:20:36  brouard
   Summary: After compiling on Visual C
 
 
 #include <limits.h>
 #include <sys/types.h>
+#include <sys/utsname.h>
 #include <sys/stat.h>
 #include <errno.h>
 /* extern int errno; */
 #include <gsl/gsl_multimin.h>
 #endif
 
+
 #ifdef NLOPT
 #include <nlopt.h>
 typedef struct {
@@ -5415,6 +5420,65 @@ calandcheckages(int imx, int maxwav, double *agemin, double *agemax, int *nberr,
     return (1);
 }
 
+syscompilerinfo()
+ {
+   /* #include "syscompilerinfo.h"*/
+#include <gnu/libc-version.h>
+#if defined(__GNUC__)
+# if defined(__GNUC_PATCHLEVEL__)
+#  define __GNUC_VERSION__ (__GNUC__ * 10000 \
+                            + __GNUC_MINOR__ * 100 \
+                            + __GNUC_PATCHLEVEL__)
+# else
+#  define __GNUC_VERSION__ (__GNUC__ * 10000 \
+                            + __GNUC_MINOR__ * 100)
+# endif
+#endif
+
+// 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)
+#elif __unix__ // all unices, not all compilers
+    // Unix
+#elif __linux__
+    // linux
+#elif __APPLE__
+    // Mac OS, not sure if this is covered by __posix__ and/or __unix__ though...
+#endif
+
+/*  __MINGW32__          */
+/*  __CYGWIN__  */
+/* __MINGW64__  */
+// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
+/* _MSC_VER  //the Visual C++ compiler is 17.00.51106.1, the _MSC_VER macro evaluates to 1700. Type cl /?  */
+/* _MSC_FULL_VER //the Visual C++ compiler is 15.00.20706.01, the _MSC_FULL_VER macro evaluates to 150020706 */
+/* _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 <stdint.h>
+#if UINTPTR_MAX == 0xffffffff
+   printf("32-bit \n"); /* 32-bit */
+#elif UINTPTR_MAX == 0xffffffffffffffff
+  printf("64-bit \n");/* 64-bit */
+#else
+ printf("wtf-bit \n"); /* wtf */
+#endif
+
+struct utsname sysInfo;
+
+   if (uname(&sysInfo) != -1) {
+      puts(sysInfo.sysname);
+      puts(sysInfo.nodename);
+      puts(sysInfo.release);
+      puts(sysInfo.version);
+      puts(sysInfo.machine);
+   }
+   else
+      perror("uname() error");
+   printf("GNU C version %d\n", __GNUC_VERSION__);
+  printf("GNU libc version: %s\n", gnu_get_libc_version());
+
+ }
 
 /***********************************************/
 /**************** Main Program *****************/
@@ -5592,6 +5656,8 @@ int main(int argc, char *argv[])
  optionfilext=%s\n\
  optionfilefiname='%s'\n",pathimach,pathtot,path,optionfile,optionfilext,optionfilefiname);
 
+  syscompilerinfo();
+
   printf("Local time (at start):%s",strstart);
   fprintf(ficlog,"Local time (at start): %s",strstart);
   fflush(ficlog);