[C++-sig] Boost Python private members problem

David Abrahams dave at boost-consulting.com
Wed Aug 23 00:18:14 CEST 2006


"Eduardo Picado" <eduardo.picado at gmail.com> writes:

> I'm facing a problem with the last module I need to compile with Boost Python.
> I receive this compilation error:
>
> Compiling...(with vc-8_0)
> TASRLogger.cpp
> C:\Python24\include\TASRLogger.hpp(353) : error C2248:
> 'TASRLogger::TASRLogger' : cannot access private member declared in
> class 'TASRLogger'
>         C:\Python24\include\TASRLogger.hpp(37) : see declaration of
> 'TASRLogger::TASRLogger'
>         C:\Python24\include\TASRLogger.hpp(33) : see declaration of 'TASRLogger'
>         This diagnostic occurred in the compiler generated function
> 'TASRDefaultLogger::TASRDefaultLogger(const TASRDefaultLogger &)'
>
> It's hard find a solution for the problem as I don't have the sources
> for the dll. Otherwise I could at least change the member attributes
> visibility.

Actually you mean access I think.  In C++ you don't get direct control
over visibility.

> Is there a workaround for it?

This is strictly illegal, of course, but I think you have only one
choice: just change the access from private to public in the header
file.  The chance of breaking something is practically nil.

Well... actually you have another choice.  You could add a friend
declaration to the header and use the friend to do the access.  But
there's not much advantage in it.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list