Hello Deric,
Your idea sounds workable for code written to accommodate it. But what about
ported code where multiple files have static functions
with the same name? As soon as the macro is set for compatibility with the
problematic debug environment, the link would fail due to
multiply defined function names. Ideally ported code can build without
modification. Also, introducing more non-standard
pseudo-keywords such as PRIVATE might bring objections.
My vote is to hold out for removal of the no static function guideline, and
live with status quo until then. Andrew said it is
possible the problem was seen only with the VS2003 tool chain. Just for fun I
gave VS2003 a try. I can say EDK2 support for VS2003
is probably ready for retirement. Its lack of 64-bit code generation capability
really limits its usefulness. Also,
BaseTools\Conf\tools_def.template is not even setup for running VS2003 from
Win64, only Win32. The fact that this has never been
fixed suggests few developers are using VS2003. Also, building various EDK2
projects with VS2003 (and even VS2005) results in build
failures more often than building them with more recent Visual Studio editions.
This is further evidence that few developers are
using the older Microsoft tools.
Thanks,
Scott
From: Deric Cole [mailto:[email protected]]
Sent: Friday, August 29, 2014 11:17 AM
To: [email protected]; 'Qiu, Shumin'
Subject: Re: [edk2] [Patch]ShellPkg: Remove 'STATIC' from function declarations
to avoid source level debugging problem
Scott,
I see your point. The problem of static variables inside functions alone pretty
much makes STATIC useless over just plain static.
But functions and variables outside functions aren't so bad. If you redefined
the macro locally, only in the driver being debugged,
then clashes would be rare (they certainly would not occur in every driver, and
you could work around them some other way if they
did).
What about two macros?
#define PERSISTENT static // for variables declared inside functions.
#define PRIVATE static // for functions and variables declared outside
functions.
I could be over-thinking this, but that seems a lot more useful to me.
-Deric
From: Scott Duplichan [mailto:[email protected]]
Sent: Thursday, August 28, 2014 9:11 PM
To: [email protected] <mailto:[email protected]>
; 'Qiu, Shumin'
Subject: Re: [edk2] [Patch]ShellPkg: Remove 'STATIC' from function declarations
to avoid source level debugging problem
Hello Deric,
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
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.
A workaround would be to make a new preprocessor macro name such as
STATIC_FUNCTION:
#if defined (WORKAROUND)
#define STATIC_FUNCTION
#else
#define STATIC_FUNCTION static
#endif
STATIC_FUNCTION void helper (void)
{
}
Workable, but pretty ugly to look at.
Thanks,
Scott
From: Deric Cole [mailto:[email protected]]
Sent: Thursday, August 28, 2014 04:08 PM
To: [email protected] <mailto:[email protected]>
; Qiu, Shumin
Subject: Re: [edk2] [Patch]ShellPkg: Remove 'STATIC' from function declarations
to avoid source level debugging problem
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?
From: Carsey, Jaben [mailto:[email protected]]
Sent: Thursday, August 28, 2014 1:11 PM
To: Qiu, Shumin
Cc: [email protected] <mailto:[email protected]>
Subject: Re: [edk2] [Patch]ShellPkg: Remove 'STATIC' from function declarations
to avoid source level debugging problem
Reviewed-by: Jaben Carsey <[email protected]
<mailto:[email protected]> >
From: Qiu, Shumin
Sent: Wednesday, August 27, 2014 7:40 PM
To: Carsey, Jaben
Cc: [email protected] <mailto:[email protected]>
Subject: [edk2][Patch]ShellPkg: Remove 'STATIC' from function declarations to
avoid source level debugging problem
Importance: High
Hi Jaben,
Can you help to review this patch? Internal linkage (ie. STATIC) functions have
caused problems with source level debugging before,
so we generally avoid STATIC in ShellPkg.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <[email protected] <mailto:[email protected]> >
Thanks
Shumin
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel