mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-07-17 23:43:43 +08:00
New macros for controlling use of weak linkage
- `UNITY_WEAK_ATTRIBUTE`, if defined, is placed before declarations of weakly linked symbols. If not manually defined, it will be automatically set to `__attribute__((weak))` on GCC and Clang, except for Clang for Win32. - `UNITY_WEAK_PRAGMA`, if defined, will cause preprocessor to emit `#pragma weak setUp`, etc. Ignored if `UNITY_WEAK_ATTRIBUTE` is defined. - `UNITY_NO_WEAK` undefines both of the above resulting in no weakly linked symbols. Work around for ThrowTheSwitch/Unity#93
This commit is contained in:
@ -292,22 +292,19 @@ extern int UNITY_OUTPUT_CHAR(int);
|
||||
//-------------------------------------------------------
|
||||
// Language Features Available
|
||||
//-------------------------------------------------------
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define UNITY_SUPPORT_WEAK __attribute__((weak))
|
||||
#if !defined(UNITY_WEAK_ATTRIBUTE) && !defined(UNITY_WEAK_PRAGMA)
|
||||
# ifdef __GNUC__ // includes clang
|
||||
# if !(defined(__WIN32__) && defined(__clang__))
|
||||
# define UNITY_WEAK_ATTRIBUTE __attribute__((weak))
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#define UNITY_SUPPORT_WEAK __attribute__((weak))
|
||||
#ifdef UNITY_NO_WEAK
|
||||
# undef UNITY_WEAK_ATTRIBUTE
|
||||
# undef UNITY_WEAK_PRAGMA
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_WEAK
|
||||
#ifdef UNITY_SUPPORT_WEAK
|
||||
#define UNITY_WEAK UNITY_SUPPORT_WEAK
|
||||
#else
|
||||
#define UNITY_WEAK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Internal Structs Needed
|
||||
|
Reference in New Issue
Block a user