[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Perl bindings for libtcc available on Linux and Windo

From: Stephan Beal
Subject: Re: [Tinycc-devel] Perl bindings for libtcc available on Linux and Windows. Mac help?
Date: Sun, 18 Aug 2013 06:15:36 +0200

On Sun, Aug 18, 2013 at 5:47 AM, David Mertens <address@hidden> wrote:
+      # Have to try harder to get CPU architecture
+      cat >arch-test.c <<EOF
+        #include <stdio.h>
+        int main() {
+          #ifdef __x86_64__
+            /* this is x86_64, not x86-64, given the logic the cpu var below */
+            printf("x86_64");
+          #elif defined __i386__
+            printf("i386");
+          #else
+            printf("unknown");
+          #endif
+        }
+      $cc arch-test.c -o arch-test
+      cpu=`./arch-test`
+      echo "arch-test gave $cpu"
+      rm arch-test
+      rm arch-test.c
+      ;;
   *) ;;

It might be simpler to use the preprocessor for that:

address@hidden:~/cvs/fossil/f2]$ echo '' > foo.h
address@hidden:~/cvs/fossil/f2]$ gcc -E -dM foo.h | grep 86
#define __x86_64 1
#define __DBL_MAX__ ((double)1.79769313486231570815e+308L)
#define __x86_64__ 1


address@hidden:~/cvs/fossil/f2]$ gcc -E -dM foo.h | grep -w __x86_64__ >/dev/null && echo "x86_64"

PS: grep has a -q (quiet) flag but it's not portable, thus the redirect to /dev/null.

assuming you have a preprocessor which can spit out all predefined macros.

----- stephan beal

reply via email to

[Prev in Thread] Current Thread [Next in Thread]