Skip to content

Commit 6144b00

Browse files
avoid name lookup ambiguity
1 parent a459d11 commit 6144b00

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

libc/src/stdio/scanf_core/reader.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919

2020
namespace LIBC_NAMESPACE_DECL {
2121
namespace scanf_core {
22-
namespace internal {
22+
// We use the name "reader_internal" over "internal" because
23+
// "internal" causes name lookups in files that include the current header to be ambigious
24+
// i.e. `internal::foo` in those files, will try to lookup in `LIBC_NAMESPACE::scanf_core::internal` over `LIBC_NAMESPACE::internal`
25+
// for e.g., `internal::ArgList` in `libc/src/stdio/scanf_core/scanf_main.h`
26+
namespace reader_internal {
2327

2428
#if defined(LIBC_TARGET_ARCH_IS_GPU)
2529
// The GPU build provides FILE access through the host operating system's
@@ -62,7 +66,7 @@ LIBC_INLINE void ungetc(int c, void *f) {
6266
}
6367
#endif // LIBC_COPT_STDIO_USE_SYSTEM_FILE
6468

65-
} // namespace internal
69+
} // namespace reader_internal
6670

6771

6872
// This is intended to be either a raw string or a buffer syncronized with the
@@ -96,7 +100,7 @@ class Reader {
96100
return output;
97101
}
98102
// This should reset the buffer if applicable.
99-
return static_cast<char>(internal::getc(input_stream));
103+
return static_cast<char>(reader_internal::getc(input_stream));
100104
}
101105

102106
// This moves the input back by one character, placing c into the buffer if
@@ -111,7 +115,7 @@ class Reader {
111115
--(rb->buff_cur);
112116
return;
113117
}
114-
internal::ungetc(static_cast<int>(c), input_stream);
118+
reader_internal::ungetc(static_cast<int>(c), input_stream);
115119
}
116120

117121
LIBC_INLINE size_t chars_read() { return cur_chars_read; }

0 commit comments

Comments
 (0)