[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
improve clang support (6)
From: |
Bruno Haible |
Subject: |
improve clang support (6) |
Date: |
Fri, 07 Aug 2020 13:27:36 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; ) |
clang supports __builtin_alloca.
On Windows, it does not have an <alloca.h> header file, and therefore the use
of alloca(...) without any header file produces a warning
warning: implicitly declaring library function 'alloca' with type 'void
*(unsigned long long)'
Therefore, the bestes choices for gnulib are
- to use __builtin_alloca, or
- to use _alloca from <malloc.h>.
Both produce identical code. But I find it more convenient to use a
compiler built-in rather than an MSVC header file.
2020-08-07 Bruno Haible <bruno@clisp.org>
Use __builtin_alloca with clang.
* lib/alloca.in.h (alloca): Define as __builtin_alloca on clang.
diff --git a/lib/alloca.in.h b/lib/alloca.in.h
index beb022c..8d9ae06 100644
--- a/lib/alloca.in.h
+++ b/lib/alloca.in.h
@@ -44,7 +44,7 @@
# endif
#endif
#ifndef alloca
-# ifdef __GNUC__
+# if defined __GNUC__ || (__clang_major__ >= 4)
# define alloca __builtin_alloca
# elif defined _AIX
# define alloca __alloca
- improve clang support (6),
Bruno Haible <=