On Tue, 18 Nov 2014 05:52:59 -0500, John Gilmore wrote:

>What is a non-static constant?  What is the rationale for, say, an
>automatic one?
> 
Bad overloading of terminology/semantics.  "static" implies that no
ESD LD is generated for the object.  Like "own" in other languages.
Absent "static" the object (possibly a constant) is to be accessible
in other translation units.

>Named and unnamed constants, literals, should properly be treated as a
>separate storage class
> 
Bad history.  The original C did not provide "const" so:

o programmers passed string literals to functions that declared them
  as "char *" rather than "const char *".

o In those days, some programmers modified string literals.

So for compatibility with traditional practice and malpractice, the
implied type of a string literal is not const.


On Tue, 18 Nov 2014 17:18:13 +0800, David Crayford wrote:
>> 
>> IIRC, the SAS/C compiler put them inline if declared "const";
>> in WSA otherwise.  I believe it does not violate ANSI C if an
>> object is declared "const" in one translation unit, with "const"
>> omitted in another, as long as it is not modified by the former.
>> Of course, this caused chaos with SAS/C.
>
>IMO, static const should be inlined like C++ does but certainly not
>extern variables.
>
I wrote "const" but not "static const".  In a non-rent compilation,
extern variables may be inlined or in a separate CSECT with no
requirement to copy to WSA. I don't believe ANSI allows "const"
to be dissociated from non-"const".

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to