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]; 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

Reply via email to