Hello,
Suppose we compile two source files to object files with:
g++ -c -std=c++14 file1.cpp file2.cpp
Now we link them to an executable.
g++ -o prog -std=c++14 file1.o file2.o
Since the above is a linker command, do we need the -std=c++14?
On 22 Jan 2022 05:32, Joseph Hesse wrote:
Hello,
Suppose we compile two source files to object files with:
g++ -c -std=c++14 file1.cpp file2.cpp
Now we link them to an executable.
g++ -o prog -std=c++14 file1.o file2.o
Since the above is a linker command, do we need the -std=c++14?
No.
At one time, probably in the 1990's? or so but I don't know, linking
changed from considering only 8 significant characters in a name, to supporting effectively arbitrarily long names.
The standardized versions of the language have never had a restriction
to 8 significant characters, but the names in the iostreams stuff and in
the C library are typical of the kind of names programmers invented to support that restriction.
Another area where linking could conceivably have had different
requirements for different versions of the language, is the use of weak symbols for `inline` things. C++17 appeared to add the possibility of `inline` variables. However, the wording for templates have had that as
a requirement that linkers had to be able to deal with, since C++98.
The only linker requirements change I know of for the standardized
language is for C++20 modules, and presumably there it's not the good
old common linker that deals with it (disclaimer: no experience).
- Alf
On 1/22/22 3:39 AM, Alf P. Steinbach wrote:
On 22 Jan 2022 05:32, Joseph Hesse wrote:
Hello,
Suppose we compile two source files to object files with:
g++ -c -std=c++14 file1.cpp file2.cpp
Now we link them to an executable.
g++ -o prog -std=c++14 file1.o file2.o
Since the above is a linker command, do we need the -std=c++14?
No.
At one time, probably in the 1990's? or so but I don't know, linking
changed from considering only 8 significant characters in a name, to
supporting effectively arbitrarily long names.
The standardized versions of the language have never had a restriction
to 8 significant characters, but the names in the iostreams stuff and
in the C library are typical of the kind of names programmers invented
to support that restriction.
Another area where linking could conceivably have had different
requirements for different versions of the language, is the use of
weak symbols for `inline` things. C++17 appeared to add the
possibility of `inline` variables. However, the wording for templates
have had that as a requirement that linkers had to be able to deal
with, since C++98.
The only linker requirements change I know of for the standardized
language is for C++20 modules, and presumably there it's not the good
old common linker that deals with it (disclaimer: no experience).
- Alf
The early versions of the standard, while not limiting identifier
length, does limit the 'significant' length for external identifiers, allowing the implementation to truncate the name of the symbol in the
output to the linker.
In C99, 6.4.2.1p5 makes that length Implementation Defined. I would have
to search to see if somewhere there is a guarantee of a minimum value
for this length
On 1/22/22 3:39 AM, Alf P. Steinbach wrote:
On 22 Jan 2022 05:32, Joseph Hesse wrote:
Hello,
Suppose we compile two source files to object files with:
g++ -c -std=c++14 file1.cpp file2.cpp
Now we link them to an executable.
g++ -o prog -std=c++14 file1.o file2.o
Since the above is a linker command, do we need the -std=c++14?
No.
At one time, probably in the 1990's? or so but I don't know, linking
changed from considering only 8 significant characters in a name, to
supporting effectively arbitrarily long names.
The standardized versions of the language have never had a restriction
to 8 significant characters, but the names in the iostreams stuff and
in the C library are typical of the kind of names programmers invented
to support that restriction.
Another area where linking could conceivably have had different
requirements for different versions of the language, is the use of
weak symbols for `inline` things. C++17 appeared to add the
possibility of `inline` variables. However, the wording for templates
have had that as a requirement that linkers had to be able to deal
with, since C++98.
The only linker requirements change I know of for the standardized
language is for C++20 modules, and presumably there it's not the good
old common linker that deals with it (disclaimer: no experience).
- Alf
The early versions of the standard, while not limiting identifier
length, does limit the 'significant' length for external identifiers, allowing the implementation to truncate the name of the symbol in the
output to the linker.
In C99, 6.4.2.1p5 makes that length Implementation Defined. I would have
to search to see if somewhere there is a guarantee of a minimum value
for this length
Am 22.01.2022 um 12:30 schrieb Richard Damon:
On 1/22/22 3:39 AM, Alf P. Steinbach wrote:
On 22 Jan 2022 05:32, Joseph Hesse wrote:
Hello,
Suppose we compile two source files to object files with:
g++ -c -std=c++14 file1.cpp file2.cpp
Now we link them to an executable.
g++ -o prog -std=c++14 file1.o file2.o
Since the above is a linker command, do we need the -std=c++14?
No.
At one time, probably in the 1990's? or so but I don't know, linking
changed from considering only 8 significant characters in a name, to
supporting effectively arbitrarily long names.
The standardized versions of the language have never had a
restriction to 8 significant characters, but the names in the
iostreams stuff and in the C library are typical of the kind of names
programmers invented to support that restriction.
Another area where linking could conceivably have had different
requirements for different versions of the language, is the use of
weak symbols for `inline` things. C++17 appeared to add the
possibility of `inline` variables. However, the wording for templates
have had that as a requirement that linkers had to be able to deal
with, since C++98.
The only linker requirements change I know of for the standardized
language is for C++20 modules, and presumably there it's not the good
old common linker that deals with it (disclaimer: no experience).
- Alf
The early versions of the standard, while not limiting identifier
length, does limit the 'significant' length for external identifiers,
allowing the implementation to truncate the name of the symbol in the
output to the linker.
In C99, 6.4.2.1p5 makes that length Implementation Defined. I would
have to search to see if somewhere there is a guarantee of a minimum
value for this length
In C++ the mangled name includes the whole signature, so a limitation
would be a problem.
On 1/22/22 10:45 AM, Bonita Montero wrote:
Am 22.01.2022 um 12:30 schrieb Richard Damon:
On 1/22/22 3:39 AM, Alf P. Steinbach wrote:
On 22 Jan 2022 05:32, Joseph Hesse wrote:
Hello,
Suppose we compile two source files to object files with:
g++ -c -std=c++14 file1.cpp file2.cpp
Now we link them to an executable.
g++ -o prog -std=c++14 file1.o file2.o
Since the above is a linker command, do we need the -std=c++14?
No.
At one time, probably in the 1990's? or so but I don't know, linking
changed from considering only 8 significant characters in a name, to
supporting effectively arbitrarily long names.
The standardized versions of the language have never had a
restriction to 8 significant characters, but the names in the
iostreams stuff and in the C library are typical of the kind of
names programmers invented to support that restriction.
Another area where linking could conceivably have had different
requirements for different versions of the language, is the use of
weak symbols for `inline` things. C++17 appeared to add the
possibility of `inline` variables. However, the wording for
templates have had that as a requirement that linkers had to be able
to deal with, since C++98.
The only linker requirements change I know of for the standardized
language is for C++20 modules, and presumably there it's not the
good old common linker that deals with it (disclaimer: no experience). >>>>
- Alf
The early versions of the standard, while not limiting identifier
length, does limit the 'significant' length for external identifiers,
allowing the implementation to truncate the name of the symbol in the
output to the linker.
In C99, 6.4.2.1p5 makes that length Implementation Defined. I would
have to search to see if somewhere there is a guarantee of a minimum
value for this length
In C++ the mangled name includes the whole signature, so a limitation
would be a problem.
Which is one reason about that time the common linkers started
supporting much longer names (and if they don't make it infinite, they sometimes need to switch to a hash of the full name at some point).
Hello,
Suppose we compile two source files to object files with:
g++ -c -std=c++14 file1.cpp file2.cpp
Now we link them to an executable.
g++ -o prog -std=c++14 file1.o file2.o
Since the above is a linker command, do we need the -std=c++14?
The early versions of the standard, while not limiting identifier
length, does limit the 'significant' length for external identifiers, allowing the implementation to truncate the name of the symbol in the
output to the linker.
In C99, 6.4.2.1p5 makes that length Implementation Defined. I would
have to search to see if somewhere there is a guarantee of a minimum
value for this length
Richard Damon <Ric...@Damon-Family.org> writes:
[...]
The early versions of the standard, while not limiting identifier
length, does limit the 'significant' length for external identifiers, allowing the implementation to truncate the name of the symbol in the output to the linker.
In C99, 6.4.2.1p5 makes that length Implementation Defined. I wouldSection 5.2.4.1 paragraph 1 says
have to search to see if somewhere there is a guarantee of a minimum
value for this length
63 significant initial characters in an internal identifier
or a macro name
31 significant initial characters in an external identifier
By the way I think you mean requirement rather than guarantee.
On Tuesday, February 1, 2022 at 10:18:25 AM UTC-5, Tim Rentsch wrote:
Richard Damon <Ric...@Damon-Family.org> writes:
[...]
The early versions of the standard, while not limiting identifier
length, does limit the 'significant' length for external identifiers,
allowing the implementation to truncate the name of the symbol in the
output to the linker.
In C99, 6.4.2.1p5 makes that length Implementation Defined. I would
have to search to see if somewhere there is a guarantee of a minimum
value for this length
Section 5.2.4.1 paragraph 1 says
"The implementation shall be able to translate and execute at
least one program that contains at least one instance of every one
of the following limits:"
63 significant initial characters in an internal identifier
or a macro name
31 significant initial characters in an external identifier
Keep in mind that these are NOT minimum permitted values for the
maximum number of significant characters in an identifier (the
so-called minimum maximum that I heard a lot about when C90 first
came out). Strictly speaking, the only requirement that they
impose is on the "one program". It is not a requirement that the implementation treat that many characters as significant if they
occur in any other program
By the way I think you mean requirement rather than guarantee.
A requirement that must be met by an implementation of a language in
order to qualify as conforming to a given standard also serves as a
guarantee that anything that does qualify as conforming
implementation of that language meets that requirement.
I think you're just wrong about that. Clearly the intended
reading of section 5.2.4, and how essentially everyone else
reads this section, is that 5.2.4.1 paragraph 1 gives minimum
translation limits, and also requires all conforming
implementations to be able to translate *and execute* a program
that has at least one instance of each of the minimums.
Conversely, any programming language standard that does not
give a requirement for minimum supported identifier length
would be grossly negligent. So it would be quite astonishing
to interpret 5.2.4.1 paragraph 1 as giving minimums that
apply to just the one program rather than stating minimum
requirements that apply to the implementation generally.
A requirement that must be met by an implementation of a language inIt is not a guarantee in the usual sense of the word guarantee.
order to qualify as conforming to a given standard also serves as a guarantee that anything that does qualify as conforming
implementation of that language meets that requirement.
And even if it were, it's a pointless observation.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 113 |
Nodes: | 8 (1 / 7) |
Uptime: | 04:40:42 |
Calls: | 2,497 |
Calls today: | 14 |
Files: | 8,644 |
Messages: | 1,901,936 |