From efed0aa7dd6157f3c4e16cb022eefa3ba942e470 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 29 Aug 2015 04:14:26 +0200 Subject: only use __attributes__ if compiling with gcc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/assert.h | 5 ++++- include/slibc/features.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 include/slibc/features.h (limited to 'include') diff --git a/include/assert.h b/include/assert.h index 7f44222..e5a963d 100644 --- a/include/assert.h +++ b/include/assert.h @@ -20,6 +20,9 @@ #include +#include + + /* The `assert` macro shall be redefined according to the the * current state of `NDEBUF` each time is included. */ @@ -86,7 +89,7 @@ __USE_GNU * @param line The line in the source code whence the assertion was made * @param func The function in the source code whence the assertion was made */ -void __attribute__((noreturn, nonnull(3, 4, 5))) +void __GCC_ONLY(__attribute__((noreturn, nonnull(3, 4, 5)))) __assert_fail(const char* expression, int errnum, const char* file, int line, const char* func); diff --git a/include/slibc/features.h b/include/slibc/features.h new file mode 100644 index 0000000..a755f71 --- /dev/null +++ b/include/slibc/features.h @@ -0,0 +1,35 @@ +/** + * slibc — Yet another C library + * Copyright © 2015 Mattias Andrée (maandree@member.fsf.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef _SLIBC_FEATURES_H +#define _SLIBC_FEATURES_H + + + +/** + * Macro used to exclude code unless GCC is used. + */ +#if defined(__GNUC__) +# define __GCC_ONLY(...) __VA_ARGS__ +#else +# define __GCC_ONLY(...) /* ignore */ +#endif + + + +#endif + -- cgit v1.2.3-70-g09d2