Skip to content

Commit

Permalink
Fix warnings caused by -Wstatic-in-inline
Browse files Browse the repository at this point in the history
Define TJEI_FORCE_INLINE as static __forceinline

This fixes the following warning(s) when built with clang on Windows:
```
warning: static function 'tjei_write' is used in an inline function with external linkage [-Wstatic-in-inline]
note: use 'static' to give inline function 'tjei_write_bits' internal linkage
note: expanded from macro 'TJEI_FORCE_INLINE'
```

Includes suggestion by @sezero
  • Loading branch information
madebr authored and sezero committed Mar 26, 2023
1 parent 0bd8290 commit 1ccf79d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tiny_jpeg.h
Expand Up @@ -173,10 +173,12 @@ int tje_encode_with_func(tje_write_func* func,


#if defined(_MSC_VER)
#define TJEI_FORCE_INLINE __forceinline
#define TJEI_FORCE_INLINE static __forceinline
// #define TJEI_FORCE_INLINE __declspec(noinline) // For profiling
#elif ((defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__))
#define TJEI_FORCE_INLINE __attribute__((always_inline)) static __inline
#else
#define TJEI_FORCE_INLINE static // TODO: equivalent for gcc & clang
#define TJEI_FORCE_INLINE static __inline
#endif

// Only use zero for debugging and/or inspection.
Expand Down

0 comments on commit 1ccf79d

Please sign in to comment.