[llvm-bugs] [Bug 37784] New: clang does not define __GNUC_GNU_INLINE__

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 12 11:21:12 PDT 2018


            Bug ID: 37784
           Summary: clang does not define __GNUC_GNU_INLINE__
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ndesaulniers at google.com
                CC: llozano at chromium.org, llvm-bugs at lists.llvm.org,
                    manojgupta at google.com, srhines at google.com

In the linux kernel, we prefer to use gnu89 semantics for extern inline
functions.  Writing a feature test for the attribute gnu_inline should be
straightforward, except that gcc did not get __has_attribute until 5.1. 
Instead, older versions of gcc define __GNUC_GNU_INLINE__ if that attribute is
supported.  It seems that clang does not, which makes writing a feature test a
little wonky:

#ifdef __GNUC_GNU_INLINE__
#define __gnu_inline __attribute__((gnu_inline))
#define __gnu_inline
#warning "No gnu inline"

produces a warning in clang.

We can likely work around this via:

#ifndef __has_attribute         // Optional of course.
#define __has_attribute(x) 0  // Compatibility with non-clang compilers.

#if defined(__GNUC_GNU_INLINE__) || __has_attribute(gnu_inline)
#define __gnu_inline __attribute__(gnu_inline)

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180612/8818c9a6/attachment.html>

More information about the llvm-bugs mailing list