Skip to content

Commit ae2612a

Browse files
danzeeemanDan Mooreclaude
authored
Fix macOS core build warnings (and bundled addons) (#8621)
* Fix compiler warnings in macOS core build and bundled addons Clears the mechanical warnings reported by a clean `make Release` of libs/openFrameworks on macOS (clang, -Wall). No behavior or API changes. Core (libs/openFrameworks): - ofEvents.cpp, ofFpsCounter.cpp: reorder constructor initializer lists to match member declaration order (-Wreorder-ctor). - ofColor.h: explicit static_cast<float> in ofColor_::limit() for the integer specializations (-Wimplicit-const-int-float-conversion). The value is unchanged; the cast only makes the existing rounding explicit. - ofPixels.cpp: remove unused local `bytesPerPixel`. - ofFileUtils.cpp: remove unused static `natural()` comparator. - ofLog.h: scope a -Wformat-security suppression around ofVAArgsToString(), which intentionally forwards a caller-supplied printf format. Existing format semantics are preserved. - ofAVFoundationVideoPlayer.m: remove unused `currentSampleRate`. - ofAVEngineSoundPlayer.mm: remove an unused `error` in init; mark variables that are only used in the iOS (#ifndef TARGET_OSX) paths as [[maybe_unused]] so iOS builds are unaffected. Bundled addons: - ofxOpenCv: add using-declarations (ofBaseDraws::draw in ofxCvContourFinder, ofxCvImage::setRoiFromPixels in ofxCvFloatImage) to stop hidden overloaded virtuals (-Woverloaded-virtual). - ofxAssimp: remove unused private field mOfTexType; mark the set-but-unused bFinishedTransition [[maybe_unused]] (referenced only in commented-out logging). - ofxSvg: remove unused local bFoundValidNextChar. Intentionally not addressed here: - -Wliteral-conversion in ofAVEngineSoundPlayer.mm (dispatch_time is given float seconds, so the delay is currently 0 ns); fixing it would change interruption timing. - OpenGL deprecation warnings (CVOpenGLTexture*, NSOpenGLContext) in ofAVFoundationPlayer.mm and ofSystemUtils.cpp; no replacement exists while core renders with OpenGL. - libs/utf8 and other external libraries. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * Fix dispatch_time delays and silence OpenGL deprecation warnings on macOS Finishes the macOS core warning cleanup started in the previous commit. A clean `make Release` of libs/openFrameworks now reports no warnings outside libs/utf8. ofAVEngineSoundPlayer.mm: dispatch_time() takes a delta in nanoseconds (int64_t), but four call sites passed float seconds (0.033f, 0.017f, 0.3f, 0.3f). The float was truncated to 0, so these "delayed" blocks actually ran on the next main-queue turn (-Wliteral-conversion). They now use the intended delays via NSEC_PER_MSEC: - 0.033f -> 33 * NSEC_PER_MSEC (interruption handling) - 0.017f -> 17 * NSEC_PER_MSEC (restore play count) - 0.3f -> 300 * NSEC_PER_MSEC (two play() retries while the session is interrupted / config change pending) This is a real behavior change: these blocks are now actually deferred. Audio interruption / route change / media-services-reset handling should be exercised in the sound examples. ofAVFoundationPlayer.mm, ofSystemUtils.cpp: the remaining -Wdeprecated-declarations are Apple's OpenGL deprecations (CVOpenGLTexture*, NSOpenGLContext). openFrameworks core renders with OpenGL and there is no drop-in replacement, so wrap just those calls in scoped `#pragma clang diagnostic push/ignored/pop` rather than disabling the warning for the whole file or build. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Dan Moore <dan@makitdoathing.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 7c08343 commit ae2612a

15 files changed

Lines changed: 50 additions & 39 deletions

File tree

‎addons/ofxAssimp/src/ofxAssimpAnimationMixer.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void AnimationMixer::update(float aElapsedTimef) {
134134
}
135135
}
136136

137-
bool bFinishedTransition = false;
137+
[[maybe_unused]] bool bFinishedTransition = false;
138138
if(isTransitioning()) {
139139
// ofLogNotice("AnimationMixer::update") << " total weights: " << getTotalClipWeights() << " | " << ofGetFrameNum();
140140
mTransitionPercent += (tdelta / mTransitionDuration);

‎addons/ofxAssimp/src/ofxAssimpTexture.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,5 @@ class Texture {
4141
of::filesystem::path texturePath;
4242
aiTextureType textureType = aiTextureType_NONE;
4343
std::string mTexTypeStr;
44-
ofMaterialTextureType mOfTexType = OF_MATERIAL_TEXTURE_DIFFUSE;
4544
};
4645
}

‎addons/ofxOpenCv/src/ofxCvContourFinder.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ofxCvContourFinder : public ofBaseDraws {
3636
// of the contour, if the contour runs
3737
// along a straight line, for example...
3838

39+
using ofBaseDraws::draw;
3940
virtual void draw() const { draw(0,0, _width, _height); };
4041
virtual void draw( float x, float y ) const { draw(x,y, _width, _height); };
4142
virtual void draw( float x, float y, float w, float h ) const;

‎addons/ofxOpenCv/src/ofxCvFloatImage.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class ofxCvFloatImage : public ofxCvImage {
6161

6262
virtual void setFromPixels( const unsigned char* _pixels, int w, int h);
6363
virtual void setFromPixels( float * _pixels, int w, int h ); //no scaling
64+
using ofxCvImage::setRoiFromPixels;
6465
virtual void setRoiFromPixels( const unsigned char* _pixels, int w, int h);
6566
virtual void setRoiFromPixels( float * _pixels, int w, int h ); //no scaling
6667
virtual void operator = ( unsigned char* _pixels );

‎addons/ofxSvg/src/ofxSvg.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,6 @@ void ofxSvg::_parsePath( ofXml& tnode, std::shared_ptr<ofxSvgPath> aSvgPath ) {
12381238

12391239
// up to next valid character //
12401240
std::string currentString;
1241-
bool bFoundValidNextChar = false;
12421241
auto pos = index+1;
12431242
if( pos >= ostring.size() ) {
12441243
// ofLogVerbose("ofxSvg") << "pos is greater than string size: " << pos << " / " << ostring.size();

‎libs/openFrameworks/events/ofEvents.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ int ofGetPreviousMouseY() {
124124

125125
ofCoreEvents::ofCoreEvents()
126126
: targetRate(60.0)
127-
, fixedRateTimeNanos(std::chrono::nanoseconds(ofGetFixedStepForFps(60.0)))
128127
, bFrameRateSet(false)
129128
, fps(60.0)
130129
, currentMouseX(0)
131130
, currentMouseY(0)
132131
, previousMouseX(0)
133132
, previousMouseY(0)
134-
, bPreMouseNotSet(false) {
133+
, bPreMouseNotSet(false)
134+
, fixedRateTimeNanos(std::chrono::nanoseconds(ofGetFixedStepForFps(60.0))) {
135135
}
136136

137137
//------------------------------------------

‎libs/openFrameworks/graphics/ofPixels.cpp‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,9 +1349,6 @@ bool ofPixels_<PixelType>::resizeTo(ofPixels_<PixelType>& dst, ofInterpolationMe
13491349
size_t srcHeight = getHeight();
13501350
size_t dstWidth = dst.getWidth();
13511351
size_t dstHeight = dst.getHeight();
1352-
size_t bytesPerPixel = getBytesPerPixel();
1353-
1354-
13551352
PixelType * dstPixels = dst.getData();
13561353

13571354
switch (interpMethod){

‎libs/openFrameworks/sound/ofAVEngineSoundPlayer.mm‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ - (instancetype)init
247247
self = [super init];
248248
if (self) {
249249
[self setupSharedSession];
250-
NSError * error = nil;
251250

252251
_mainMixer = [[self engine] mainMixerNode];
253252
_mainMixer.outputVolume = 0.98;
@@ -315,7 +314,7 @@ - (instancetype)init
315314
/* pausing stops the audio engine and the audio hardware, but does not deallocate the resources allocated by prepare().
316315
When your app does not need to play audio, you should pause or stop the engine (as applicable), to minimize power consumption.
317316
*/
318-
bool isPlaying = [weak_self isPlaying] || weak_self.bIsPlaying == YES;
317+
[[maybe_unused]] bool isPlaying = [weak_self isPlaying] || weak_self.bIsPlaying == YES;
319318
if (!weak_self.isSessionInterrupted && !weak_self.isConfigChangePending) {
320319

321320

@@ -353,7 +352,7 @@ - (instancetype)init
353352
}
354353

355354

356-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.033f), dispatch_get_main_queue(), ^{
355+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 33 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
357356
[weak_self handleInterruption:note];
358357
});
359358

@@ -369,8 +368,8 @@ - (instancetype)init
369368
- (void) handleMediaServicesReset:(NSNotification *)notification {
370369

371370

372-
NSUInteger interruptionType;
373-
UInt8 reasonValue;
371+
[[maybe_unused]] NSUInteger interruptionType;
372+
[[maybe_unused]] UInt8 reasonValue;
374373
#ifndef TARGET_OSX
375374
interruptionType = [notification.userInfo[AVAudioSessionInterruptionTypeKey] unsignedIntegerValue];
376375
#endif
@@ -400,7 +399,7 @@ - (void) handleMediaServicesReset:(NSNotification *)notification {
400399

401400
- (void) handleRouteChange:(NSNotification *)notification {
402401

403-
NSUInteger interruptionType;
402+
[[maybe_unused]] NSUInteger interruptionType;
404403
UInt8 reasonValue = 0;
405404

406405
#ifndef TARGET_OSX
@@ -522,7 +521,7 @@ - (void) makeEngineConnections {
522521
- (void)endInterruption {
523522
NSLog(@"AVEnginePlayer::endInterruption");
524523

525-
NSError *error;
524+
[[maybe_unused]] NSError *error;
526525
#ifndef TARGET_OSX
527526
bool success = [[AVAudioSession sharedInstance] setActive:YES error:&error];
528527
if (!success)
@@ -559,7 +558,7 @@ - (void)endInterruption {
559558

560559
__typeof(self) __weak weak_self = self;
561560

562-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.017f), dispatch_get_main_queue(), ^{
561+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 17 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
563562
weak_self.mRestorePlayCount--;
564563
if(weak_self.bIsPlaying == NO) return;
565564
[weak_self play:posSecs];
@@ -606,7 +605,7 @@ - (BOOL)loadWithURL:(NSURL*)url {
606605
- (void)startEngine{
607606

608607
NSError * error = nil;
609-
BOOL engineRunning = NO;
608+
[[maybe_unused]] BOOL engineRunning = NO;
610609
BOOL problem = NO;
611610
if( ![[self engine] isRunning] ){
612611
[[self engine] startAndReturnError:&error];
@@ -724,7 +723,7 @@ - (void)play:(float)startTime{
724723
}
725724
if(_isSessionInterrupted || _isConfigChangePending){
726725
__typeof(self) __weak weak_self = self;
727-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3f), dispatch_get_main_queue(), ^{
726+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 300 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
728727
[weak_self play:startTime];
729728
});
730729
return;
@@ -856,7 +855,7 @@ - (void)stop {
856855
}
857856

858857
if(_isSessionInterrupted || _isConfigChangePending){
859-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3f), dispatch_get_main_queue(), ^{
858+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 300 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
860859
__typeof(self) __weak weak_self = self;
861860
[weak_self stop];
862861
});

‎libs/openFrameworks/types/ofColor.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ ofColor_<PixelType> operator*(float val, const ofColor_<PixelType> &color) {
722722

723723
template<typename PixelType>
724724
inline float ofColor_<PixelType>::limit() {
725-
return std::numeric_limits<PixelType>::max();
725+
return static_cast<float>(std::numeric_limits<PixelType>::max());
726726
}
727727

728728
template<>

‎libs/openFrameworks/utils/ofFileUtils.cpp‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,18 +1469,6 @@ void ofDirectory::reset(){
14691469
close();
14701470
}
14711471

1472-
//------------------------------------------------------------------------------------------------------------
1473-
static bool natural(const ofFile& a, const ofFile& b) {
1474-
string aname = a.getBaseName(), bname = b.getBaseName();
1475-
int aint = ofToInt(aname), bint = ofToInt(bname);
1476-
if(ofToString(aint) == aname && ofToString(bint) == bname) {
1477-
return aint < bint;
1478-
} else {
1479-
return a < b;
1480-
}
1481-
}
1482-
1483-
14841472
//------------------------------------------------------------------------------------------------------------
14851473
struct StringSort{
14861474
fs::path path;

0 commit comments

Comments
 (0)