Re: [RFC] Interim review: typedefs.h / structs.h splitting

From: Kinkie <gkinkie_at_gmail.com>
Date: Tue, 2 Oct 2012 14:45:53 +0200

On Sun, Sep 30, 2012 at 12:06 PM, Amos Jeffries <squid3_at_treenet.co.nz> wrote:
> On 28/09/2012 4:10 a.m., Alex Rousskov wrote:
>>
>> On 09/27/2012 12:48 AM, Amos Jeffries wrote:
>>>
>>> On 26/09/2012 4:44 a.m., Kinkie wrote:
>>>>
>>>> Hi all,
>>>> this new patch addresses the concerns that were raised.
>>>> It stops short of removing typedefs.h (but structs.h is now gone).
>>>>
>>>> It doesn't break the build on the farm; it is in my opinion reasonably
>>>> complete and it is for me a merge-candidate.
>>>>
>>>
>>> I see a lot of externs being removed in .h files. All fine and well for
>>> statically linked .o files. But when these files are shuffled into
>>> librares the ABI linking operates a little different and is known to
>>> strip away symbol references for "internal" objects (ie those with no
>>> explicit extern marking). Please be wary of that.
>>
>> Are you sure that such stripping happens in C++ context (rather than
>> some old C context)? AFAIK, C++ function declarations have external C++
>> linking scope by default, so they all should have "extern" marking from
>> the linker point of view.
>
>
> Moderately sure. I ran into it in trunk recently when moving functions to
> one of the libraries. I forget which.
>
> That might have been a fluke case, but think worth at least checking up on
> explicitly for the general case before doing this big merge.

From http://stackoverflow.com/questions/1358400/what-is-external-linkage-and-internal-linkage-in-c
:

-----------------------
You can explicitly control the linkage of a symbol by using the extern
and static keywords and the default linkage is extern for non-const
symbols and static (internal) for const symbols.

// in namespace or global scope
int i; // extern by default
const int ci; // static by default
extern const int eci; // explicitly extern
static int si; // explicitly static

// the same goes for functions (but there are no const functions)
int foo(); // extern by default
static int bar(); // explicitly static
------------------------

We can of course explicitly mark functions as "extern", but this
source agrees with Alex that it's not needed.

If there's no objections, I plan to merge to trunk tomorrow.

-- 
    /kinkie
Received on Tue Oct 02 2012 - 12:46:00 MDT

This archive was generated by hypermail 2.2.0 : Wed Oct 03 2012 - 12:00:05 MDT