[if gte mso 9]>
Subject: Re: [edk2] [Patch]ShellPkg: Remove 'STATIC' from function declarations to avoid source level debugging problem
From: "Scott Duplichan" <email@example.com>
Date: 2014-09-02 07:49:01
Andrew Fish [mailto:firstname.lastname@example.org] wrote:
On Aug 28, 2014, at 9:11 PM, Scott Duplichan <email@example.com> wrote:
You are right about the possibility of redefining STATIC. The problem with doing so is that STATIC is used in 3 unrelated ways:
1) static functions
2) static variables declared inside of a function
Maybe we should just use static for this.
That sounds good. Because of the 3 or 4 different ways static is used in C code, it is hard to imagine how STATIC defined to something other than static could be useful.
3) static variables declared outside of functions
If STATIC is defined as nothing, all 3 uses have problems:
1) The few static (STATIC) functions that remain in EDK2 become public functions and can clash with existing public functions with the same name. Example: AllocateMemoryBelow4G() in LockBoxDxe.c becomes public and clashes with the one in AcpiS3SaveDxe.lib.
2) Static variables declared inside a function become local variables, something entirely different than intended. Example, line 48 of EmbeddedPkg\Ebl\HwDebug.c.
3) Static variables declared outside of functions become public, making a clash possible.
The global variable naming convention should prevent this, if followed. Prefix m or g on the global.
A workaround would be to make a new preprocessor macro name such as STATIC_FUNCTION:
#if defined (WORKAROUND)
#define STATIC_FUNCTION static
STATIC_FUNCTION void helper (void)
Workable, but pretty ugly to look at.
Maybe we should figure out if any currently supported debuggers have an issue with static, and if they don’t drop the STATIC from the coding style requirements.
That sounds like a good approach to me.
For Xcode/clang, I know that lldb does not have any issues debugging static functions for global variables.
That is good to hear.
Is this the whole point of defining “STATIC” rather than using the keyword “static”, that it can be redefined (locally) if it causes problems like this?
Reviewed-by: Jaben Carsey <Jaben.firstname.lastname@example.org>
Video for Nerds. Stuff that matters.
edk2-devel mailing list