Skip to content

Conversation

@prashanthsakapuram
Copy link

@prashanthsakapuram prashanthsakapuram commented Jan 15, 2026

Summary

Adds comprehensive documentation for ABSL_FLAGS_STRIP_NAMES to clarify its
actual behavior on mobile platforms. This addresses confusion about why flags
mysteriously don't work on iOS and Android.

Issue

Closes #1875

Problem

The macro name ABSL_FLAGS_STRIP_NAMES is misleading:

  • It refers to stripping string literals, but actually DISABLES flag registration
  • When set to 1 on mobile platforms, absl::ParseCommandLine() fails silently
  • Users porting code to iOS face "Unknown command line flag" errors
  • No clear documentation explains why or how to fix it

Solution

Enhanced documentation in two files:

Changes in absl/flags/config.h

  • Expanded comment explaining that the macro controls flag registration, not just stripping
  • Added clear behavior sections for when ABSL_FLAGS_STRIP_NAMES=1 vs 0
  • Documented mobile platform defaults (Android, iOS, embedded Apple devices)
  • Added practical examples showing how to enable flags on mobile:
    • Bazel: bazel build --define=ABSL_FLAGS_STRIP_NAMES=0
    • CMake: cmake -DABSL_FLAGS_STRIP_NAMES=0
    • Direct compilation: g++ -DABSL_FLAGS_STRIP_NAMES=0

Changes in absl/flags/flag.h

  • Added comment explaining the FlagRegistrar do_register parameter
  • Clarified that do_register=false disables registration (happens when STRIP_NAMES=1)
  • Cross-referenced config.h for detailed documentation

Testing

  • Documentation only - no behavioral changes
  • All existing tests continue to pass
  • No new tests needed

Related

Checklist

  • Follows Google C++ Style Guide
  • Documentation is clear and comprehensive
  • No code behavior changes
  • Ready for review

Addresses issue abseil#1875: Add comprehensive documentation explaining the behavior
of ABSL_FLAGS_STRIP_NAMES on mobile platforms.

This macro's name is misleading. While it refers to stripping string literals,
its actual effect is to DISABLE flag registration entirely, preventing
absl::ParseCommandLine() from working.

Changes:
- Expanded config.h comments with detailed explanation of the macro's real
  effect on flag registration (true disables registration, false enables it)
- Added information about mobile platform defaults (Android, iOS, embedded)
- Included practical examples for users who need flags on mobile platforms
- Added comments to flag.h explaining the FlagRegistrar do_register parameter

This will help users (especially those porting code to iOS/Android) understand
why their flags mysteriously don't work and how to fix it.
@prashanthsakapuram
Copy link
Author

@derekmauro can review the changes , Which closes the issue #1875

Thank You!

@prashanthsakapuram prashanthsakapuram deleted the docs/flags-strip-names-documentation branch January 15, 2026 18:32
@prashanthsakapuram prashanthsakapuram restored the docs/flags-strip-names-documentation branch January 15, 2026 18:54
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.

[Bug]: Effect of ABSL_FLAGS_STRIP_NAMES on mobile platforms is poorly documented

1 participant