On 04/24/19 19:09, Ard Biesheuvel wrote:
> On Wed, 24 Apr 2019 at 18:59, Kinney, Michael D
> <michael.d.kin...@intel.com> wrote:
>>
>> Hi Ard,
>>
>> I see a mix of use of 'static' and 'STATIC' in the sources.
>>
>> The reason to use STATIC is if it needs to be replaced with
>> something other than 'static' for a specific compiler or
>> debug scenario.
>>
>> Long ago, there were some source level debug issue with
>> 'static' symbols, so using the macro STATIC was preferred
>> so it could be mapped to nothing for a debug scenario. That
>> issue no long exists.
>>
>> Do you know of a reason today to map 'STATIC' to anything
>> Other than 'static'?
>>
>> I also looked at the EDK II C Coding Standard.  It is also
>> inconsistent and had references to both 'static' and 'STATIC'.
>> We should enter a few BZs to update that doc once we have
>> clear guidance from this discussion.
>>
> 
> I wasn't aware that lower case static is also in use, so I was simply
> extrapolating from personal experience.

+1

> i think there should be no reason to use the preprocessor to change
> 'static' into something else, and so I'm happy to settle on lowercase
> static, as long as we are consistent.

+1 (same for CONST / const)

> But more importantly, now that
> this has come up, what I would like to do is make 'static' mandatory
> unless the code requires otherwise: this results in much better code
> generation (given that the compiler can infer constness for non-const
> static variables but not for ones with external linkage) and generally
> improves programmer hygiene when it comes to linking to arbitrary
> symbols that are really internal to a library.

I agree; for new code, giving internal linkage to as many as possible
objects that have static storage duration is the way to go. ("Make as
many globals 'static' as you can.")

Thanks
Laszlo

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#39655): https://edk2.groups.io/g/devel/message/39655
Mute This Topic: https://groups.io/mt/31318888/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to