A C++ question: when to use "friend class"/"friend template"

Mojca Miklavec mojca at macports.org
Mon Aug 19 15:38:21 PDT 2013


On Sun, Aug 18, 2013 at 10:45 AM, Joshua Root wrote:
> On 2013-8-18 16:55 , Mojca Miklavec wrote:
>> Hello,
>>
>> While this might not be the most appropriate list to ask this type
>> questions, I hope that there is someone who might be able to help.
>>
>> When trying to upgrade a port (hugin-app in particular) I had to
>> modify the following code:
>>
>>  #ifdef __GNUC__
>>  friend class Notify::self_type;
>>  #else
>>  friend typename Notify::self_type;
>>  #endif
>>
>> The Clang compiler (Xcode Xcode 4.6.3 on Lion) failed to work with
>> "friend class Notify::self_type;". As a temporary patch I removed
>> #ifdef and made the compiler always end up seeing the code "friend
>> typename Notify::self_type;", but I believe that this will break the
>> gcc compilers (I didn't try though because compilation takes forever).
>>
>> Does anyone know what the proper patch should be?
>>
>> Thank you,
>>     Mojca
>>
>> PS: the latest version of hugin-app claims to work with wxWidgets 2.9
>> even though it's stated to be experimental. But most problems with
>> compiling that new version arise from linking to boost.
>
> It's hard to infer what the code is trying to accomplish from that one
> snippet.

Here is the context:
    http://sourceforge.net/p/hugin/hugin/ci/default/tree/src/foreign/vigra/vigra/cachedfileimage.hxx

> But AIUI 'friend typename' is not valid in standards prior to
> C++11.

So is there any
    #ifdef __CXX11
? ;)

> And if self_type is not in fact a class, declaring it to be one
> here may well result in undefined behaviour.

I filed a bug report. Let's see what they will answer:
    https://bugs.launchpad.net/hugin/+bug/1213586

The port seems to be broken because of problems with boost anyway.

Thank you,
    Mojca


More information about the macports-dev mailing list