No. You simply used *casting* .
k=*(int *)(buffer +4) etc etc.
You do have to be careful with this as it's not guaranteed that the
compiler won't take liberties in arranging members of a struct for >optimization purposes, ...
According to John Ames <commodorejohn@gmail.com>:
No. You simply used *casting* .
k=*(int *)(buffer +4) etc etc.
You do have to be careful with this as it's not guaranteed that the
compiler won't take liberties in arranging members of a struct for
optimization purposes, ...
No, the C Standard says:
Within a structure object, the non-bit-field members and the units in which bit-fields
reside have addresses that increase in the order in which they are declared.
There can be bits of padding to get fields aligned as needed, but no reordering.
It is pretty common to use structure declarations with common fields at the front to do varriant records.
On 1/2/26 13:26, John Levine wrote:
No, the C Standard says:
Within a structure object, the non-bit-field members and the units in which bit-fields
reside have addresses that increase in the order in which they are declared.
There can be bits of padding to get fields aligned as needed, but no reordering.
It is pretty common to use structure declarations with common fields at the >> front to do varriant records.
Hmmm ... with arrays of simple types you can
advance the pointer by 'x' and get the 'x'-th
element. In theory you can manually peek 'x'
(times type) bytes ahead in memory too.
Is that not for-sure correct with variant records ?
length = nchars;memcpy((void *)p->data, (void *)srcstring, strlen(srcstring));
On Fri, 2 Jan 2026 08:49:25 -0800, John Ames wrote:
... it's not guaranteed that the compiler won't take liberties in
arranging members of a struct for optimization purposes ...
The C23 spec (section 6.2.5, ?Types?) does say the member objects of a
struct type need to be ?sequentially allocated?.
r objects of... it's not guaranteed that the compiler won't take liberties in
arranging members of a struct for optimization purposes ...
The C23 spec (section 6.2.5, ?Types?) does say the membe
a struct type need to be ?sequentially allocated?.
That language has been there a long time. It's in my copy of C11 and
it wasn't new then. It's probably always been there since we wrote
code that used the common struct prefix hack in K&R C.
On Fri, 2 Jan 2026 20:32:53 -0000 (UTC), John Levine wrote:
C doesn't have variant records, but you can fake them with structures
with common initial fields. The different structures can be different
sizes so the usual approach is to malloc() them one at a time and use a
pointer to it.
Another approach is to have a struct containing union of structs with a
flag in the top level struct indicating which child struct to use in the >union. The structs in the union can also have unions so you can build a
real octopus.
According to rbowman <bowman@montana.com>:
On Fri, 2 Jan 2026 20:32:53 -0000 (UTC), John Levine wrote:
C doesn't have variant records, but you can fake them with structures
with common initial fields. The different structures can be different
sizes so the usual approach is to malloc() them one at a time and use a
pointer to it.
Another approach is to have a struct containing union of structs with a >>flag in the top level struct indicating which child struct to use in the >>union. The structs in the union can also have unions so you can build a >>real octopus.
That works but the union is the size of the largest struct so it can waste
a lot of space compared to allocating each struct's actual size. I realize this doesn't work for arrays of structs or unions, but it works fine for arrays of pointers to them.
It appears that c186282 <c186282@nnada.net> said:
On 1/2/26 13:26, John Levine wrote:
No, the C Standard says:
Within a structure object, the non-bit-field members and the units in which bit-fields
reside have addresses that increase in the order in which they are declared.
There can be bits of padding to get fields aligned as needed, but no reordering.
It is pretty common to use structure declarations with common fields at the >>> front to do varriant records.
Hmmm ... with arrays of simple types you can
advance the pointer by 'x' and get the 'x'-th
element. In theory you can manually peek 'x'
(times type) bytes ahead in memory too.
Is that not for-sure correct with variant records ?
C doesn't have variant records, but you can fake them with structures with >common initial fields. The different structures can be different sizes
so the usual approach is to malloc() them one at a time and use a pointer to it.
As bonus confusion, C allows the last field in a structure to be an array of >unspecified size, e.g.
struct countedstring {
int length;
char data[];
};
Then for a string of innitialized from srcstring you'd say something like:
struct countedstring *p = malloc(sizeof(struct countedstring) + strlen(srcstring));
length = nchars;memcpy((void *)p->data, (void *)srcstring, strlen(srcstring));
On Sat, 3 Jan 2026 07:03:38 -0500, Chris Ahlstrom wrote:
I once created an audio playback app with class hierarchies in C, rather
than C++. It was an interesting experiment, and it worked. But that's
the last time I tried that.
A class is a glorified struct. I remember heated discussions at one of the Boston Computer Society's meeting before 'C++' became a name about 'C with Classes' and whether a new language was needed.
'C with Classes' is now a derogatory term that describes the sort of C++ I write. Charles Petzhold has written a number of books on programming for Windows. He has an intense dislike for C++ so if you can track down some
of the first editions of 'Programming Windows' they are all C. The 6th edition was C# which he said was what should have been all along.
The C approach was educational since it exposed some of the magic lke vtables, and the magical 'this' is only another parameter passed in the first location.
On Sat, 3 Jan 2026 07:03:38 -0500, Chris Ahlstrom wrote:
I once created an audio playback app with class hierarchies in C, rather
than C++. It was an interesting experiment, and it worked. But that's
the last time I tried that.
A class is a glorified struct. I remember heated discussions at one of the Boston Computer Society's meeting before 'C++' became a name about 'C with Classes' and whether a new language was needed.
'C with Classes' is now a derogatory term that describes the sort of C++ I write. Charles Petzhold has written a number of books on programming for Windows. He has an intense dislike for C++ so if you can track down some
of the first editions of 'Programming Windows' they are all C. The 6th edition was C# which he said was what should have been all along.
On 2026-01-03 20:43, rbowman wrote:
On Sat, 3 Jan 2026 07:03:38 -0500, Chris Ahlstrom wrote:
I once created an audio playback app with class hierarchies in C, rather >>> than C++. It was an interesting experiment, and it worked. But that's
the last time I tried that.
A class is a glorified struct. I remember heated discussions at one of the >> Boston Computer Society's meeting before 'C++' became a name about 'C with >> Classes' and whether a new language was needed.
'C with Classes' is now a derogatory term that describes the sort of C++ I >> write. Charles Petzhold has written a number of books on programming for
Windows. He has an intense dislike for C++ so if you can track down some
of the first editions of 'Programming Windows' they are all C. The 6th
edition was C# which he said was what should have been all along.
What's the difference between C++ and C#? (I don't know how to pronounce that one).
I don't really agree that C# is easier. You still have to develop
a mental model of the language and master adjunct frameworks like
.NET.
What's the difference between C++ and C#? (I don't know how to
pronounce that one).
On Sun, 4 Jan 2026 21:17:05 -0000 (UTC), Lawrence D?Oliveiro wrote:
On Sun, 4 Jan 2026 15:14:30 +0100, Carlos E.R. wrote:
What's the difference between C++ and C#? (I don't know how to
pronounce that one).
It?s spelled ?C#?, but it?s pronounced ?C??.
For once sanity prevailed and they didn't use a character that would have been a pain in the ass evermore.
Carlos E.R. wrote this post by blinking in Morse code:
On 2026-01-03 20:43, rbowman wrote:
On Sat, 3 Jan 2026 07:03:38 -0500, Chris Ahlstrom wrote:
I once created an audio playback app with class hierarchies in C, rather >>>> than C++. It was an interesting experiment, and it worked. But that's
the last time I tried that.
A class is a glorified struct. I remember heated discussions at one of the >>> Boston Computer Society's meeting before 'C++' became a name about 'C with >>> Classes' and whether a new language was needed.
'C with Classes' is now a derogatory term that describes the sort of C++ I >>> write. Charles Petzhold has written a number of books on programming for >>> Windows. He has an intense dislike for C++ so if you can track down some >>> of the first editions of 'Programming Windows' they are all C. The 6th
edition was C# which he said was what should have been all along.
What's the difference between C++ and C#? (I don't know how to pronounce
that one).
C-sharp. (Get it? Get it?)
AI Overview
C++ and C# are both derived from the C language family but
target different programming needs:
C++ offers high performance and low-level hardware control,
making it ideal for systems programming and game engines,
while C# provides a managed, higher-level environment for
easier and faster development of web, desktop, and mobile
applications
Kind of analogous to C++ versus Java.
I don't really agree that C# is easier. You still have to develop
a mental model of the language and master adjunct frameworks like
.NET.
On Sun, 04 Jan 2026 19:41:11 GMT, Charlie Gibbs wrote:
On 2026-01-04, Chris Ahlstrom <OFeem1987@teleworm.us> wrote:
I don't really agree that C# is easier. You still have to develop a
mental model of the language and master adjunct frameworks like .NET.
Does C# qualify as a Microsoft proprietary language?
Or are there implementations on OSes other than Windows (and compilers,
either open source or available from other vendors)?
https://www.mono-project.com/
Sort of... Using the dotnet sdk on Windows or Linux is sort of like
using venv in Python or the express generator with node/express.
dotnet new console -n world
creates a new console application in the 'world' directory with the
director structure and a very minimalist Program.cs with
Console.WriteLine("Hello, World!");
dotnet build followed by
$ dotnet run
Hello, World!
works. Packages are added with Nuget, which is like npm or pip.
https://www.nuget.org/
It's free and open source but the entire ecosystem uses the .NET
terminology. I doubt anyone who has no experience developing on Windows
is going to pick C#. It's not that different from Java except it was initially a Windows only language and not sold as cross platform, run anywhere, from the beginning.
On Sun, 4 Jan 2026 15:14:30 +0100, Carlos E.R. wrote:
On 2026-01-03 20:43, rbowman wrote:
On Sat, 3 Jan 2026 07:03:38 -0500, Chris Ahlstrom wrote:
I once created an audio playback app with class hierarchies in C,
rather than C++. It was an interesting experiment, and it worked. But
that's the last time I tried that.
A class is a glorified struct. I remember heated discussions at one of
the Boston Computer Society's meeting before 'C++' became a name about
'C with Classes' and whether a new language was needed.
'C with Classes' is now a derogatory term that describes the sort of
C++ I write. Charles Petzhold has written a number of books on
programming for Windows. He has an intense dislike for C++ so if you
can track down some of the first editions of 'Programming Windows' they
are all C. The 6th edition was C# which he said was what should have
been all along.
What's the difference between C++ and C#? (I don't know how to pronounce
that one).
C Sharp. In the late '90s Microsoft released Visual J++, their implementation of Java. I still have the media with an IDE similar to
Visual Studio. It was quite nice but did not meet Sun's purity test so Sun sued Microsoft.
C# was released in the early 2000s, with Hejlsberg as the principal
designer.
https://en.wikipedia.org/wiki/Anders_Hejlsberg
He'd also developed J++ so C# incorporated the lessons learned from that
as well as C++. I don't really like C++ and find C# a lot better for
Windows programming. Mono was an early attempt to make it cross platform
and is still around. The alternative is to install the .NET SDK.
https://learn.microsoft.com/en-us/dotnet/core/install/linux
That includes the csc compiler:
$ csc
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
On Linux the ability to build GUIs has been problematic. There i a Gtk# library but I've never used it.
https://www.mono-project.com/docs/gui/gtksharp/
You can do both console and ASP .NET backend apps. For kicks, I did a
command line app to download information from the iTunes database in
Python and C#. The syntax differs of course but the complexity is very similar compared to doing it in C or C++.
Since csc emits an IL that depends on the framework runtime by passing
flags you can build Linux packages on Windows and vice versa. You can also target ARM devices.
https://learn.microsoft.com/en-us/dotnet/iot/deployment
MS managed to create more confusion that normal. .NET Framework was the standard runtime on Windows boxes. The .NET Core project was aimed at
cross platform solutions and had its own numbering so .NET Core 3.x was contemporaneous with .NET Framework 4.7x. At that point they decided Core was the future so .NET 5.0 was .NET Core with .NET Framework 4.8 being
the last of what everone called .NET. .NET 10 is the current release.
On 2026-01-04 15:43, Chris Ahlstrom wrote:
Carlos E.R. wrote this post by blinking in Morse code:
What's the difference between C++ and C#? (I don't know how to pronounce >>> that one).
C-sharp. (Get it? Get it?)
Mmm... no, I don't think I get it. Maybe something cultural in it.
What's the difference between C++ and C#? (I don't know how to
pronounce that one).
C-sharp. (Get it? Get it?)
On Sun, 4 Jan 2026 09:43:40 -0500
Chris Ahlstrom <OFeem1987@teleworm.us> wrote:
What's the difference between C++ and C#? (I don't know how to
pronounce that one).
C-sharp. (Get it? Get it?)
The impish might prefer "C-hash" ;P
On Sun, 4 Jan 2026 09:43:40 -0500
Chris Ahlstrom <OFeem1987@teleworm.us> wrote:
What's the difference between C++ and C#? (I don't know how to
pronounce that one).
C-sharp. (Get it? Get it?)
The impish might prefer "C-hash" ;P
On Sun, 4 Jan 2026 09:43:40 -0500
Chris Ahlstrom <OFeem1987@teleworm.us> wrote:
What's the difference between C++ and C#? (I don't know how to
pronounce that one).
C-sharp. (Get it? Get it?)
The impish might prefer "C-hash" ;P
I once created an audio playback app with class hierarchies in C,
rather than C++. It was an interesting experiment, and it worked. But
that's the last time I tried that.
Carlos E.R. wrote this post by blinking in Morse code:
What's the difference between C++ and C#? (I don't know how to
pronounce that one).
C-sharp. (Get it? Get it?)
Mmm... no, I don't think I get it. Maybe something cultural in it.
C-pound ...
On 5 Jan 2026 18:10:08 GMT, Niklas Karlsson wrote:
C-pound ...
?Cœ??
On 2026-01-05, Lawrence D?Oliveiro <ldo@nz.invalid> wrote:
On 5 Jan 2026 18:10:08 GMT, Niklas Karlsson wrote:
C-pound ...
?Cœ??
# is often spoken as "pound" in the USA. Notably when instructing
someone to enter things on a phone keypad.
On 5 Jan 2026 23:28:43 GMT, Niklas Karlsson wrote:
On 2026-01-05, Lawrence D?Oliveiro <ldo@nz.invalid> wrote:
On 5 Jan 2026 18:10:08 GMT, Niklas Karlsson wrote:
C-pound ...
?Cœ??
# is often spoken as "pound" in the USA. Notably when instructing
someone to enter things on a phone keypad.
I have no idea why.
On 2026-01-06, Lawrence D?Oliveiro <ldo@nz.invalid> wrote:
On 5 Jan 2026 23:28:43 GMT, Niklas Karlsson wrote:
On 2026-01-05, Lawrence D?Oliveiro <ldo@nz.invalid> wrote:
On 5 Jan 2026 18:10:08 GMT, Niklas Karlsson wrote:
C-pound ...
?Cœ??
# is often spoken as "pound" in the USA. Notably when instructing
someone to enter things on a phone keypad.
I have no idea why.
In days of yore, "#" was often used by dealers in bulk products as
an abbreviation for pounds weight. For instance, a sack of chicken
feed might consist of "50# laying mash".
On 2026-01-05, Lawrence D?Oliveiro <ldo@nz.invalid> wrote:
On 5 Jan 2026 18:10:08 GMT, Niklas Karlsson wrote:
C-pound ...
?Cœ??
# is often spoken as "pound" in the USA. Notably when instructing
someone to enter things on a phone keypad.
On 5 Jan 2026 23:28:43 GMT, Niklas Karlsson wrote:
On 2026-01-05, Lawrence D?Oliveiro <ldo@nz.invalid> wrote:
On 5 Jan 2026 18:10:08 GMT, Niklas Karlsson wrote:
C-pound ...
?Cœ??
# is often spoken as "pound" in the USA. Notably when instructing
someone to enter things on a phone keypad.
I have no idea why.
unds",In days of yore, "#" was often used by dealers in bulk products as
an abbreviation for pounds weight. For instance, a sack of chicken
feed might consist of "50# laying mash".
Most of us used ?lb?.
https://en.wikipedia.org/wiki/Number_sign#Usage
"When ?#? is after a number, it is read as "pound" or "po
meaning the unit of weight.[54][55] The text "5# bag of flour" would
mean "five- pound bag of flour". This is rare outside North America."
Most of us don't live in New Zealand.
On 6 Jan 2026 06:24:00 GMT
rbowman <bowman@montana.com> wrote:
In days of yore, "#" was often used by dealers in bulk products as
an abbreviation for pounds weight. For instance, a sack of chicken
feed might consist of "50# laying mash".
Most of us used ?lb?.
https://en.wikipedia.org/wiki/Number_sign#Usage
"When ?#? is after a number, it is read as "pound" or "pounds",
meaning the unit of weight.[54][55] The text "5# bag of flour" would
mean "five- pound bag of flour". This is rare outside North America."
Most of us don't live in New Zealand.
That's been obscure even in the US for many a year, frankly - but the
legacy pronunciation of # survives to this day.
That's been obscure even in the US for many a year, frankly - but
the legacy pronunciation of # survives to this day.
I suspect that this is because "pound" is (at least somewhat)
easier and faster to pronounce than the others. As we all know,
convenience trumps just about everything else - remember the
"baud" vs "bps" confusion.
On Tue, 06 Jan 2026 18:57:03 GMT
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:
That's been obscure even in the US for many a year, frankly - but
the legacy pronunciation of # survives to this day.
I suspect that this is because "pound" is (at least somewhat)
easier and faster to pronounce than the others. As we all know,
convenience trumps just about everything else - remember the
"baud" vs "bps" confusion.
Seems plausible - may also have to do with phone-tree systems and how intelligible "hash" is or isn't over a muffled line, vs. a word that
begins and ends with hard consonants.
remember theIIRC the are not , strictly, the same thing...
"baud" vs "bps" confusion.
Seems plausible - may also have to do with phone-tree systems and
how intelligible "hash" is or isn't over a muffled line, vs. a word
that begins and ends with hard consonants.
I hadn't thought of that angle. Indeed, aeronautical radio
phraseology has evolved to deal with just that sort of problem.
On Wed, 07 Jan 2026 06:33:45 GMT
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:
Seems plausible - may also have to do with phone-tree systems and
how intelligible "hash" is or isn't over a muffled line, vs. a word
that begins and ends with hard consonants.
I hadn't thought of that angle. Indeed, aeronautical radio
phraseology has evolved to deal with just that sort of problem.
Many's the time I've had to resort to the NATO phonetic alphabet when
trying to get a customer to type something in over the phone.
Many's the time I've had to resort to the NATO phonetic alphabet when
trying to get a customer to type something in over the phone.
On Wed, 7 Jan 2026 09:48:29 +0000, The Natural Philosopher wrote:
On 06/01/2026 18:57, Charlie Gibbs wrote:
remember the "baud" vs "bps" confusion.
IIRC the are not , strictly, the same thing...
They usually were back in the 1200 baud days. Then things got
complicated.
John Ames wrote this post by blinking in Morse code:
On Wed, 07 Jan 2026 06:33:45 GMT
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:
Seems plausible - may also have to do with phone-tree systems and
how intelligible "hash" is or isn't over a muffled line, vs. a word
that begins and ends with hard consonants.
I hadn't thought of that angle. Indeed, aeronautical radio
phraseology has evolved to deal with just that sort of problem.
Many's the time I've had to resort to the NATO phonetic alphabet when
trying to get a customer to type something in over the phone.
Like "It all went tango uniform"? A real "charlie foxtrot"?
| Sysop: | Tetrazocine |
|---|---|
| Location: | Melbourne, VIC, Australia |
| Users: | 15 |
| Nodes: | 8 (0 / 8) |
| Uptime: | 40:52:32 |
| Calls: | 188 |
| Files: | 21,502 |
| Messages: | 80,790 |