Every time I do a survey of C codebases, I tend to get about the
same set of results:
* On average functions have only around three local variables
* 80% of all functions have 4 locals or fewer
I don't find such stats a compelling reason for block scopes,
[...] An observation pointed out to me at my last gig, and that
I now point out occasionally myself, is that Linux (for example)
is not so much written in C but rather in Linux C, which is the
dialect of the language defined by the compilers they use and
the specific behaviors they force using flags, pragmas, etc, for
those compilers.
At any rate, it's certainly not strictly
conforming ISO C: is _any_ large program strictly conforming at
this point? I suspect many projects strive for such, but few
actually attain it.
cross@spitfire.i.gajendra.net (Dan Cross) writes:
[...] An observation pointed out to me at my last gig, and that
I now point out occasionally myself, is that Linux (for example)
is not so much written in C but rather in Linux C, which is the
dialect of the language defined by the compilers they use and
the specific behaviors they force using flags, pragmas, etc, for
those compilers.
Any program accepted by a conforming implementation is a C program.
That remains true even if the program relies on compiler options
such as -fwrap or -fno-strict-aliasing, or takes advantage of
specific behaviors chosen by the compiler in situations that the C
standard deems undefined behavior, or uses non-standard #pragmas
that the implementation has chosen to define. As long as the
implementation stays inside the bounds of being conforming, any
program it accepts is written in C. Writing in a subset of the full
language doesn't change that: a C program that has no 'goto'
statements in it is still a C program. The same reasoning applies
to programs that make use of -fwrapv, etc.
At any rate, it's certainly not strictly
conforming ISO C: is _any_ large program strictly conforming at
this point? I suspect many projects strive for such, but few
actually attain it.
I expect most people don't realize how high a bar it is to write a C
program that is strictly conforming. Except for toy examples I
don't think I've ever seen one. I wouldn't advocate choosing such a >criterion. Even more than that, if a member of any team I was part
of did suggest doing so I would strongly argue against it. Even if
it could be done, which I think is unlikely, the amount of effort
needed to do so would be prohibitive.
In article <86se72bd74.fsf@linuxsc.com>,
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
cross@spitfire.i.gajendra.net (Dan Cross) writes:
[...] An observation pointed out to me at my last gig, and that
I now point out occasionally myself, is that Linux (for example)
is not so much written in C but rather in Linux C, which is the
dialect of the language defined by the compilers they use and
the specific behaviors they force using flags, pragmas, etc, for
those compilers.
Any program accepted by a conforming implementation is a C program.
That remains true even if the program relies on compiler options
such as -fwrap or -fno-strict-aliasing, or takes advantage of
specific behaviors chosen by the compiler in situations that the C
standard deems undefined behavior, or uses non-standard #pragmas
that the implementation has chosen to define. As long as the
implementation stays inside the bounds of being conforming, any
program it accepts is written in C. Writing in a subset of the full
language doesn't change that: a C program that has no 'goto'
statements in it is still a C program. The same reasoning applies
to programs that make use of -fwrapv, etc.
This is quibbling, but for the record, Linux is written in an
_extended_ subset of ISO C, and makes use of a number of
non-conforming extensions (e.g., GCC-style function attributes
and so on).
Can you give me an example of a real-world programming language in which
the scope of a local variable begins at the start of the enclosing
block, rather than at its declaration / definition?
On 21/05/2026 19:26, Bart wrote:
On 21/05/2026 13:55, David Brown wrote:
(The separation of the struct/union/enum tag name space from variable
namespace /is/ a feature that people use
Urgh, another discussion. Let's not go there. Suffice that it is unique
to C.
the fact that in c a language/compiler sees only functions or variablesAre you talking about symbol conflicts when converting internal linkage
that are up in code is a disaster
it is a disaster becouse it dont alow you to split code on N files
each file has realted functions and variables and not to care on the
global order of it
On 16/05/2026 23:03, fir wrote:
the fact that in c a language/compiler sees only functions or
variables that are up in code is a disaster
it is a disaster becouse it dont alow you to split code on N files
each file has realted functions and variables and not to care on the
global order of it
I mentioned something like this a week ago, suggesting that in C it was harder work than necessary to split one source file up into two or more.
However, some of the regulars here seemed to think it was a non-problem:
| Sysop: | Jacob Catayoc |
|---|---|
| Location: | Pasay City, Metro Manila, Philippines |
| Users: | 4 |
| Nodes: | 4 (0 / 4) |
| Uptime: | 494928:20:28 |
| Calls: | 162 |
| Files: | 568 |
| D/L today: |
14 files (349K bytes) |
| Messages: | 74,957 |