Skip to content

Conversation

@scchn
Copy link

@scchn scchn commented Nov 17, 2025

Replace if (DEBUG) with #ifdef DEBUG since DEBUG is not defined in release mode.

Summary by CodeRabbit

  • Refactor
    • Internal debugging infrastructure optimized with improved compile-time conditionals for enhanced build efficiency. No user-visible changes.

@coderabbitai
Copy link

coderabbitai bot commented Nov 17, 2025

Walkthrough

The deb debug logging macro in LanScan.m was refactored to be DEBUG-aware at compile time. In DEBUG builds, it expands to a do-while block that logs messages; in non-DEBUG builds, it becomes a no-op. The macro now uses a standard do-while wrapper for safety.

Changes

Cohort / File(s) Summary
Debug macro refactor
Sources/LanScanInternal/LanScan.m
Replaced #ifndef-guarded deb macro with DEBUG-conditional version using do-while(0) wrapper; logs only in DEBUG builds, compiles to no-op otherwise

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Standard do-while macro pattern is well-established; verify DEBUG macro is properly defined in build configuration
  • Confirm macro behavior in both DEBUG and non-DEBUG build paths to ensure no unintended logging overhead

Poem

🐰 A macro once guarded with #ifndef's care,
Now dances with DEBUG in debug-time flair!
Do-while wraps round it, safe from mishap,
Logging in debug, silent in app—
A rabbit's delight, this preprocessor snap! 🌟

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix compilation error in release build' directly and specifically describes the main change: resolving a compilation error that occurs in release builds by replacing if (DEBUG) with #ifdef DEBUG.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@scchn scchn force-pushed the fix/compilation_err branch from 21ffc67 to a7c3325 Compare November 17, 2025 05:25
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
Sources/LanScanInternal/LanScan.m (1)

34-40: LGTM! Compilation error fix is correct.

The use of #ifdef DEBUG and #else preprocessor directives correctly solves the compilation error in release builds where DEBUG is undefined. The do-while(0) wrapper on both branches ensures the macro is safe in all statement contexts.

Optional: Consider renaming __oo to avoid reserved identifier.

The variable name __oo uses a double underscore prefix, which is technically reserved for the implementation per C/C++ standards. While this is common practice in macros and unlikely to cause issues, consider using a single underscore prefix (e.g., _dbg_str) or a different pattern to be strictly standards-compliant.

-#define deb(format, ...) do { NSString *__oo = [NSString stringWithFormat: @"%s:%@", __PRETTY_FUNCTION__, [NSString stringWithFormat:format, ## __VA_ARGS__]]; NSLog(@"%@", __oo); } while(0)
+#define deb(format, ...) do { NSString *_dbg_str = [NSString stringWithFormat: @"%s:%@", __PRETTY_FUNCTION__, [NSString stringWithFormat:format, ## __VA_ARGS__]]; NSLog(@"%@", _dbg_str); } while(0)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21ffc67 and a7c3325.

📒 Files selected for processing (1)
  • Sources/LanScanInternal/LanScan.m (1 hunks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant