Home | News | Documentation | Download

Creating nested class with private access modifier

A strange behavior occurs when I try to create a shared library for a cpp (e.g. test.cpp) file (by typing .L test.cpp++ in ROOT interpreter). The header file (e.g. test.h) defines a nested class (A::B) with private access modifier. I got the following error

test_cc_ACLiC_dict.cxx: In function 'ROOT::TGenericClassInfo* ROOT::GenerateInitInstanceLocal(const A::B*)':
/afs/cern.ch/user/c/chlcheng/CodeBase/TRootProcessor/macros/test/src/test_cc_ACLiC_dict.cxx:103:67: error: 'class A::B' is private within this context

Here is the definition of the header and cpp file:

In test.h:

class A{
class B{};

In test.cpp:

#include "test.h"

This error only occurs when the header file is placed in the same folder as the cpp file. If I put the header file to some other folder, no error will pop up. Is there any way to get around this? Thanks a lot.

Hi @AlkaidC,

I invite @Axel to have a look.

Hi @AlkaidC ,

This part:

is really intriguing. Are you sure that it doesn’t pick up a different header?

Anyway - this reminded me of https://sft.its.cern.ch/jira/browse/ROOT-9112 . Fixing that also fixed your issue! I’m working on the fix and a test - more updates soon! Thanks for your report!

It is likely/plausible ACLiC is then not requesting the dictionary for the content of the header (assuming it might not be related to the script).

In my original script I put my header in another folder i.e. macros/inc/ and my cpp file in the folder macros/src/. The shared library can be created without any error and all the class methods work just fine.