PaulS & econjack:
Thanks for your replies. The information is helpful.
...that would be better than general hand-waving.
The problem I have is I don't know what I don't know. I had a project wherein I was getting duplicate definitions error. I had thought that the #include guards would only allow a .h file to be added to the project once. When you (PaulS) mentioned the "duplicate definition error" that got my attention.
As a way for me to learn more about this let me describe the situation I had.
I had a .h file which defined two const strings - an SSID and passcode - which were to be used in two different .cpp files in the project. In a .h file I had,
const char[] SSID = "\"mySSID\"";
Not germane to my central concern here, but, to avoid confusion, the included quotes as part of the SSID string are necessary for where it is going to be used.
I had that code in a .h file, with #include guards, and #included it in two different .cpp files in the project. I kept getting the duplicate definition error, which I thought the #include guards were there to prevent. That is, I thought the #include guards were there to prevent the .h file from being read more than once. Then I read,
The include guards prevent a given include file from being included more than once in a compilation unit.
What is meant by a "compilation unit"? Does it mean a single combination of a .cpp file and any #included .h files?
If I understand what else has been said, I could solve my problem by having that sample code in a .h file. That .h file, when #included in one .cpp file will both declare and define the string SSID with global scope. For use in the second .cpp file I would put in its .h file, or directly in the .cpp file,
extern const char[] SSID;
Will that work? Does the const modifier change anything?
Thanks for taking the time.