[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Problem compiling cml/cmapi/src/CM_cache.cpp on RHEL4 (gcc 3.4.4)



Scott,

It appears that this problem is with gcc and not the code.  See the
following snippet from the gcc release notes:

In case of friend declarations, every name used in the friend
declaration must be accessible at the point of that declaration.
Previous versions of G++ used to be less strict about this and allowed
friend declarations for private class members, for example.  See the ISO
C++ Standard Committee's defect report #209
(http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#209) for
details.

According to defect report #209, the temporary workaround is to befriend
the entire class, CML::Internal::CertCache rather than just the
LoadTrustAnchor method. If you have further problems let me know.  You
may also want to go back to gcc 3.3.x for now and this should fix the
problems as well.

--Tom

-----Original Message-----
From: owner-imc-cml@xxxxxxxxxxxx [mailto:owner-imc-cml@xxxxxxxxxxxx] On
Behalf Of Scott Rankin
Sent: Monday, December 05, 2005 5:08 PM
To: imc-cml@xxxxxxx
Subject: Problem compiling cml/cmapi/src/CM_cache.cpp on RHEL4 (gcc
3.4.4)


Hello,
I am a newbie trying to build the smp. I have encountered a problem when
trying to compile CM_cache.cpp. There is a member function from the
CertCache class named LoadTrustAnchor. It is declared as a friend in the
CachedCert class however it is not in scope (because it is a private
member function of CertCache) when the compiler tries to compile
CM_cache.h.

Here is the tail of the build log:
make[2]: Entering directory
`/home/scott/src/ssc/pki/trunk/src/smp/cml/cmlasn/src'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory
`/home/scott/src/ssc/pki/trunk/src/smp/cml/cmlasn/src'
(/bin/sh /home/scott/src/ssc/pki/trunk/src/smp/build/mkinstalldirs
/home/scott/src/ssc/pki/trunk/src/smp/../SMPDist/include/smp)
(/bin/sh /home/scott/src/ssc/pki/trunk/src/smp/build/mkinstalldirs
/home/scott/src/ssc/pki/trunk/src/smp/../SMPDist/include/smp/Modules)
(cd cmapi/inc; cp -f *.h
/home/scott/src/ssc/pki/trunk/src/smp/../SMPDist/include/smp)
(cd cmapi/src; make)
make[2]: Entering directory
`/home/scott/src/ssc/pki/trunk/src/smp/cml/cmapi/src'
g++ -c -fPIC -Wall -DLinux -D_UNIX  -I../../cmapi/inc -I../../cmlasn/inc
-I../../crlsrv_dll/inc -I../../../pkcs11_cryptopp/inc -I../../srl/inc
-I/usr/local/include/esnacc/c++ CM_cache.cpp -o CM_cache.o
In file included from CM_cache.cpp:21:
../../cmapi/inc/CM_cache.h:285: error: `short int
CML::Internal::CertCache::LoadTrustAnchor(const CML::TrustAnchor&,
CML::ErrorInfoList*)' is private
../../cmapi/inc/CM_cache.h:364: error: within this context


A generic representation of this is:
friend.h
//==========================================================
class B;

class A
{
 private:
	int x;
	int f();
};

class B
{
 public:
	friend int A::f();
};
//==========================================================

friend.cpp
//==========================================================
#include "friend.h"

int A::f()
{
	return 0;
}
//==========================================================

[scott@choke scratch]$ g++ -c -fPIC -Wall -DLinux friend.cpp -o friend.o
In file included from friend.cpp:1:
friend.h:7: error: `int A::f()' is private
friend.h:13: error: within this context



Short of modifying the CertCache class and moving this member function
public does anyone have any suggestions? I tried making CachedCert a
friend of class CertCache (as a test) but this generated more compiler
errors than this initial error.

cheers,
scott