[LLVMdev] darwin dragon-egg build issues

Jack Howarth howarth at bromo.med.uc.edu
Tue Apr 13 08:03:53 PDT 2010


On Tue, Apr 13, 2010 at 04:06:45PM +0200, Duncan Sands wrote:
> Hi Jack,
>
>>     Doesn't i386_static.diff represent a violation of...
>>
>> https://www.securecoding.cert.org/confluence/display/seccode/DCL36-C.+Do+not+declare+an+identifier+with+conflicting+linkage+classifications
>>
>> since it first declares a function as extern and then
>> redefines it locally?
>
> I don't think so.  "Redefines it locally" is not the same as giving it internal
> linkage.  By the way, if it was a problem, how would header files work?  It is
> common practice to declare a function in a header file, eg "header.h" and then
> include that header file in the file defining the function, eg "body.c".  For
> example:
>
> header.h:
>
> void foo(void);
>
> body.c:
>
> #include "header.h"
>
> void foo(void) {
> ...
> }
>
> After the preprocessor runs, you get:
>
> body.i
>
> void foo(void);
>
> void foo(void) {
> ...
> }
>
> which is equivalent to what you get from my patch.  If this results in
> undefined behavior, then a lot of software out there is broken!
>
> Note that AFAIK
>
> void foo(void);
>
> and
>
> extern void foo(void);
>
> are equivalent.
>
> Ciao,
>
> Duncan.

Duncan,
   Can't we drop the extern from the patch and use something like...

void foo(void) __attribute__(externally_visible);

as described in http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html?
                Jack




More information about the llvm-dev mailing list