Sujet : Re: encapsulating directory operations
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 23. May 2025, 22:31:40
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250523142024.453@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-05-23, Scott Lurndal <
scott@slp53.sl.home> wrote:
Kaz Kylheku <643-408-1753@kylheku.com> writes:
On 2025-05-23, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
Richard Harnden <richard.harnden@gmail.invalid> writes:
On 22/05/2025 23:32, Keith Thompson wrote:
"Paul Edwards" <mutazilah@gmail.com> writes:
[...]
In one of your library's headers:
extern const char ESCAPE;
In the corresponding *.c file:
const char ESCAPE = ('z' - 'a' == 25 ? '\x1b' : '\x27');
Change the name if you prefer.
>
Wouldn't that be a reserved identifier?
>
Yes, it would. Good catch.
>
(Identifiers starting with E followed by either a digit or an uppercase
letter are reserved; they could be defined as macros in <errno.h>.)
>
But C99 introduced, for instance "double round(double);".
>
If you had programs which used that as a file scope identifier
where <float.h> was included, or an external name, you had a clash.
>
[ ...]
Along with a couple dozen other new floating point functions. All
of which are defined in <math.h>. The only potential conflict in
code written prior to C99 would be applications that include <math.h>
and defined their own 'round' function.
1. What are the odds that a program which defines its own round function
might also include <math.h>?
2. round is not only something declared in a header, but a name with
external linkage which may have only one definition. If you're able
to define round as an external name in your program, that's not due
to a requirement coming from ISO C.
3. Even if you're able to override the platform's external names in
your program, you will not get away with that in a large project
with third party dependencies. As soon as something wants to
call the C99 round functon or the POSIX stat function,
your clashing external definition for round or stat becomes
a problem. You can really only gat away with "external name
squatting" in solo projects with no dependencies, or projects of a
similar nature and scope.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca