Alternative fix for unused functions warnings on stb_truetype.h (and stb_image.h)

This commit is contained in:
ubkp 2023-08-09 21:12:02 -03:00
parent 0959f6ebf6
commit 1615c42ea6
4 changed files with 53 additions and 37 deletions

View File

@ -7758,6 +7758,14 @@ STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user
return stbi__is_16_main(&s); return stbi__is_16_main(&s);
} }
// Workaround to hide the following unused functions warnings while compiling raylib
void unused_stb_image(void)
{
(void)&stbi__addints_valid;
(void)&stbi__mul2shorts_valid;
return;
}
#endif // STB_IMAGE_IMPLEMENTATION #endif // STB_IMAGE_IMPLEMENTATION
/* /*

View File

@ -4964,6 +4964,41 @@ STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const
return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2); return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2);
} }
// Workaround to hide the following unused functions warnings while compiling raylib
void unused_stb_truetype(void)
{
(void)&stbtt_CompareUTF8toUTF16_bigendian;
(void)&stbtt_FindMatchingFont;
(void)&stbtt_GetNumberOfFonts;
(void)&stbtt_BakeFontBitmap;
(void)&stbtt_GetFontNameString;
(void)&stbtt_FreeSDF;
(void)&stbtt_GetPackedQuad;
(void)&stbtt_GetScaledFontVMetrics;
(void)&stbtt_PackFontRange;
(void)&stbtt_PackSetSkipMissingCodepoints;
(void)&stbtt_PackSetOversampling;
(void)&stbtt_PackEnd;
(void)&stbtt_PackBegin;
(void)&stbtt_GetBakedQuad;
(void)&stbtt_MakeCodepointBitmap;
(void)&stbtt_MakeCodepointBitmapSubpixelPrefilter;
(void)&stbtt_GetGlyphBitmap;
(void)&stbtt_FreeBitmap;
(void)&stbtt_GetCodepointBitmapBox;
(void)&stbtt_GetCodepointSVG;
(void)&stbtt_FreeShape;
(void)&stbtt_GetFontBoundingBox;
(void)&stbtt_GetFontVMetricsOS2;
(void)&stbtt_GetCodepointKernAdvance;
(void)&stbtt_GetKerningTable;
(void)&stbtt_GetKerningTableLength;
(void)&stbtt_IsGlyphEmpty;
(void)&stbtt_GetCodepointBox;
(void)&stbtt_GetCodepointShape;
return;
}
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif

View File

@ -71,21 +71,12 @@
#include <ctype.h> // Required for: toupper(), tolower() [Used in TextToUpper(), TextToLower()] #include <ctype.h> // Required for: toupper(), tolower() [Used in TextToUpper(), TextToLower()]
#if defined(SUPPORT_FILEFORMAT_TTF) #if defined(SUPPORT_FILEFORMAT_TTF)
#if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
#define STB_RECT_PACK_IMPLEMENTATION #define STB_RECT_PACK_IMPLEMENTATION
#include "external/stb_rect_pack.h" // Required for: ttf font rectangles packaging #include "external/stb_rect_pack.h" // Required for: ttf font rectangles packaging
#define STBTT_STATIC #define STBTT_STATIC
#define STB_TRUETYPE_IMPLEMENTATION #define STB_TRUETYPE_IMPLEMENTATION
#include "external/stb_truetype.h" // Required for: ttf font data reading #include "external/stb_truetype.h" // Required for: ttf font data reading
#if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic pop
#endif
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View File

@ -138,11 +138,6 @@
defined(SUPPORT_FILEFORMAT_PIC) || \ defined(SUPPORT_FILEFORMAT_PIC) || \
defined(SUPPORT_FILEFORMAT_PNM)) defined(SUPPORT_FILEFORMAT_PNM))
#if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
#define STBI_MALLOC RL_MALLOC #define STBI_MALLOC RL_MALLOC
#define STBI_FREE RL_FREE #define STBI_FREE RL_FREE
#define STBI_REALLOC RL_REALLOC #define STBI_REALLOC RL_REALLOC
@ -150,10 +145,6 @@
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include "external/stb_image.h" // Required for: stbi_load_from_file() #include "external/stb_image.h" // Required for: stbi_load_from_file()
// NOTE: Used to read image data (multiple formats support) // NOTE: Used to read image data (multiple formats support)
#if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic pop
#endif
#endif #endif
#if (defined(SUPPORT_FILEFORMAT_DDS) || \ #if (defined(SUPPORT_FILEFORMAT_DDS) || \
@ -162,18 +153,9 @@
defined(SUPPORT_FILEFORMAT_PVR) || \ defined(SUPPORT_FILEFORMAT_PVR) || \
defined(SUPPORT_FILEFORMAT_ASTC)) defined(SUPPORT_FILEFORMAT_ASTC))
#if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
#define RL_GPUTEX_IMPLEMENTATION #define RL_GPUTEX_IMPLEMENTATION
#include "external/rl_gputex.h" // Required for: rl_load_xxx_from_memory() #include "external/rl_gputex.h" // Required for: rl_load_xxx_from_memory()
// NOTE: Used to read compressed textures data (multiple formats support) // NOTE: Used to read compressed textures data (multiple formats support)
#if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic pop
#endif
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOI) #if defined(SUPPORT_FILEFORMAT_QOI)
@ -3301,12 +3283,12 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
memcpy(pSrcPixel + x*bytesPerPixel, pSrcPixel, bytesPerPixel); memcpy(pSrcPixel + x*bytesPerPixel, pSrcPixel, bytesPerPixel);
} }
// Repeat the first row data for all other rows // Repeat the first row data for all other rows
int bytesPerRow = bytesPerPixel * (int)rec.width; int bytesPerRow = bytesPerPixel * (int)rec.width;
for (int y = 1; y < (int)rec.height; y++) for (int y = 1; y < (int)rec.height; y++)
{ {
memcpy(pSrcPixel + (y*dst->width)*bytesPerPixel, pSrcPixel, bytesPerRow); memcpy(pSrcPixel + (y*dst->width)*bytesPerPixel, pSrcPixel, bytesPerRow);
} }
} }
// Draw rectangle lines within an image // Draw rectangle lines within an image