¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

CAT Transmit


 

All:

The final version of the code is about to be released by Al and I and we are turning it over to Oliver to care for it in the future. There are coding style differences that some people will disagree with, and that's fine. Jerry has be active in working with the code and prefers another style. What follows is my response to some of the questions he raised.

=============

It is kinda a matter of choice and style. As to finding function prototypes, I have tried to maintain those alphabetically in the SDT.h header file. I've done the same for globals. The problem is that more than one person is editing the code and header file(s).

Also, you landed on one of my pet peeves: the confusion between the terms "define" and "declare". They are not the same terms. You said:

A class definition doesn't assign storage.

That is incorrect. From the 2nd edition of the K&R C book, page 210:

??? Declarations specify the interpretation given to each identifier; they do not necessarily reserve storage associated with the identifier. Declarations that reserve storage are called definitions.

The first sentence above means that a declaration creates an attribute list for each variable and stores it in the symbol table. Because declarations do not allocate storage for the variable, that attribute list will NOT contain an entry that specifies where in memory to find that variable. This memory location is called the lvalue of a variable. (What a variable contains is called the rvalue. The terms lvalue and rvalue are likely hangovers from assembly language programming for location (lvalue) and register (rvalue) concepts.) It is only after a definition of the variable that it has an lvalue that can be added to the attribute list found in the symbol table.

If anyone still thinks they are the same, then have them explain the need for the C extern keyword. The extern keyword was created specifically because of the need to use a variable in one file when it is defined in another file. The data declaration in one file:

??? extern int myVariable;

says to the compiler: "I know this variable is not defined in this file, but you can assume it's an int variable named myVariable and it is defined elsewhere in the program." Think of the compiler generating the code for the variable but instead of suppling the variable's lvalue, it leaves "????" in the generated code where the lvalue should be. Then, in the Arduino environment, in the INO file we find the definition of myVariable:

??? int myVariable;

which is the program statement that defines the variable myVariable. This definition allocates storage and allows the compiler to fill in the lvalue for this variable in the symbol table. Now, after the compiler finishes, the linker comes along looking at the generated code from the compiler and sees the ???? marker in the object file, looks in the symbol table for ???? in the symbol table, and substitutes that variable's lvalue for the ???? marker. When it's done with that, the linker continues to stitch in the code from the libraries and any other extern declarations to generate the final program code.

Using the terms define and declare as if they are the same concepts is wrong, but most programmers fail to make the distinction. Indeed, even Microsoft's documentation treats the two terms the same. Programming is confusing enough without confusing the terms that are integral to it.

Jack, W8TEE


?
On Saturday, February 15, 2025 at 10:59:24 AM EST, jerry <jerry@...> wrote:


? I'm not a fan of this coding approach where class methods are defined
> in a header file...I just don't like to see executable code in a
> header file. Nor do I like the idea of each cpp file having it's own
> header file. I just seems like clutter to me. On the other side, I
> think this was written by Paul and I have the utmost respect for his
> code. Kinda a rock/hard-place for me.
>
> Jack, W8TEE

I OTOH like the idea of a matching header file for each .cpp file.?
Having
everything in SDT.h seems.... like clutter.? Lots of scanning up & down
in
that huge file.? How to find the prototypes to call stuff in CAT.cpp??
Easy,
they're in CAT.h.? No scanning up & down.

Aesthetically, that giant SDT.h file gives me a similar feeling to
seeing
a few zillion global variables.

You and Al architected the T41 as a collection of small modules with
well
defined functions and interfaces that can be dropped in & out.? I feel
that
the software should be the same way.? A .cpp file/.h file pair with well
defined
interfaces that can be dropped in & out.? So - for example - if I want a
CW
keyer in another project, I can grab cw_keyer.cpp and cw_keyer.h, and I
pretty
much have it.? Yeah, I'll have to tweak them for another architecture,
but I won't have to go scanning through some giant file to find the bits
that correspond.

I do agree on the concept of not having anything whatsoever executable
inside an include file.? Or rather - not having anything that assigns
storage.
A class definition doesn't assign storage.? But it still looks messy.

? I did use the USB output on another project.? It worked fine.? It
should
work here too.? Time to get to work.


? ? ? ? ? ? ? ? - Jerry


--
Jack, W8TEE