Skip to content

Commit f2bac70

Browse files
committed
Fix macOS clang warnings: RAND_MAX float cast, char comparison, deprecated sprintf, std::string include
1 parent 3754c0e commit f2bac70

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/Processing.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@
4545
// Uncomment + drop stb_image_write.h to enable saveFrame()/save():
4646
// #define STB_IMAGE_WRITE_IMPLEMENTATION
4747
#define STB_IMAGE_WRITE_IMPLEMENTATION
48+
#pragma clang diagnostic push
49+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
50+
#pragma GCC diagnostic push
51+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
4852
#include "stb_image_write.h"
53+
#pragma clang diagnostic pop
54+
#pragma GCC diagnostic pop
4955

5056
// ── Manual glu replacements (no GLU header needed) ───────────────────────────
5157
static void _gluPerspective(double fovY_deg, double aspect, double zNear, double zFar) {
@@ -2210,7 +2216,7 @@ void PApplet::drawTTFStr(float x, float y, const ::std::string& s) {
22102216
glColor4f(fillR, fillG, fillB, fillA);
22112217
float cx = x;
22122218
for (char ch : s) {
2213-
if (ch < 32 || ch >= 128) continue;
2219+
if ((unsigned char)ch < 32 || (unsigned char)ch >= 128) continue;
22142220
stbtt_aligned_quad q;
22152221
stbtt_GetBakedQuad(g_ttf.chars, g_ttf.atlasW, g_ttf.atlasH,
22162222
ch - 32, &cx, &y, &q, 1);

src/Processing.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,12 @@ class PVector {
375375
// Static constructors
376376
static PVector fromAngle(float a, float len=1.0f) { return PVector(::std::cos(a)*len, ::std::sin(a)*len); }
377377
static PVector random2D() {
378-
float a = static_cast<float>(rand()) / RAND_MAX * 6.28318f;
378+
float a = static_cast<float>(rand()) / (float)RAND_MAX * 6.28318f;
379379
return fromAngle(a);
380380
}
381381
static PVector random3D() {
382-
float t = static_cast<float>(rand()) / RAND_MAX * 6.28318f;
383-
float p = ::std::acos(2.0f * static_cast<float>(rand()) / RAND_MAX - 1.0f);
382+
float t = static_cast<float>(rand()) / (float)RAND_MAX * 6.28318f;
383+
float p = ::std::acos(2.0f * static_cast<float>(rand()) / (float)RAND_MAX - 1.0f);
384384
return PVector(::std::sin(p)*::std::cos(t), ::std::sin(p)*::std::sin(t), ::std::cos(p));
385385
}
386386

0 commit comments

Comments
 (0)