Skip to content

Commit 72bfab4

Browse files
committed
Avoid redefining macros defined by the system
In particular, OpenBSD already defines __GNUC_PREREQ__, __BEGIN_DECLS, and __warn_references. Hiding the definitions behind #ifndef guards avoids warnings when building.
1 parent 48c6c2c commit 72bfab4

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/bsd_cdefs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@
7878
/*
7979
* Macro to test if we're using a specific version of gcc or later.
8080
*/
81+
#ifndef __GNUC_PREREQ__
8182
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
8283
#define __GNUC_PREREQ__(ma, mi) \
8384
(__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
8485
#else
8586
#define __GNUC_PREREQ__(ma, mi) 0
8687
#endif
88+
#endif /* __GNUC_PREREQ__ */
8789

8890
/*
8991
* Compiler-dependent macro to help declare pure (no side effects) functions.

src/cdefs-compat.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#ifndef _CDEFS_COMPAT_H_
22
#define _CDEFS_COMPAT_H_
33

4+
#if !defined(__BEGIN_DECLS)
45
#if defined(__cplusplus)
56
#define __BEGIN_DECLS extern "C" {
67
#define __END_DECLS }
78
#else
89
#define __BEGIN_DECLS
910
#define __END_DECLS
1011
#endif
12+
#endif /* !defined(__BEGIN_DECLS) */
1113

1214
#ifdef __GNUC__
1315
#ifndef __strong_reference
@@ -25,18 +27,22 @@
2527
#define __weak_reference(sym,alias) \
2628
__asm__(".weak " #alias); \
2729
__asm__(".equ " #alias ", " #sym)
30+
#ifndef __warn_references
2831
#define __warn_references(sym,msg) \
2932
__asm__(".section .gnu.warning." #sym); \
3033
__asm__(".asciz \"" msg "\""); \
3134
__asm__(".previous")
35+
#endif /* __warn_references */
3236
#else
3337
#define __weak_reference(sym,alias) \
3438
__asm__(".weak alias"); \
3539
__asm__(".equ alias, sym")
40+
#ifndef __warn_references
3641
#define __warn_references(sym,msg) \
3742
__asm__(".section .gnu.warning.sym"); \
3843
__asm__(".asciz \"msg\""); \
3944
__asm__(".previous")
45+
#endif /* __warn_references */
4046
#endif /* __STDC__ */
4147
#elif defined(__clang__) /* CLANG */
4248
#ifdef __STDC__
@@ -53,16 +59,20 @@
5359
#define __weak_reference(sym,alias) \
5460
__asm__(".stabs \"_" #alias "\",11,0,0,0"); \
5561
__asm__(".stabs \"_" #sym "\",1,0,0,0")
62+
#ifndef __warn_references
5663
#define __warn_references(sym,msg) \
5764
__asm__(".stabs \"" msg "\",30,0,0,0"); \
5865
__asm__(".stabs \"_" #sym "\",1,0,0,0")
66+
#endif /* __warn_references */
5967
#else
6068
#define __weak_reference(sym,alias) \
6169
__asm__(".stabs \"_/**/alias\",11,0,0,0"); \
6270
__asm__(".stabs \"_/**/sym\",1,0,0,0")
71+
#ifndef __warn_references
6372
#define __warn_references(sym,msg) \
6473
__asm__(".stabs msg,30,0,0,0"); \
6574
__asm__(".stabs \"_/**/sym\",1,0,0,0")
75+
#endif /* __warn_references */
6676
#endif /* __STDC__ */
6777
#endif /* __ELF__ */
6878
#endif /* __weak_reference */

0 commit comments

Comments
 (0)