# Namespace in my own library

**URL:** <https://root-forum.cern.ch/t/namespace-in-my-own-library/32365>\
**Category:** ROOT\
**Created:** [January 20, 2019, 6:40am UTC](https://root-forum.cern.ch/t/namespace-in-my-own-library/32365 "2019-01-20T06:40:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![oxon](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oxon/32/12641_2.png) [@oxon](https://root-forum.cern.ch/u/oxon)\
**Post date:** [January 20, 2019, 6:40am UTC](https://root-forum.cern.ch/t/namespace-in-my-own-library/32365/1 "2019-01-20T06:40:02Z")

</div>

* * *

_ROOT Version:_ 6.14.06  
_Platform:_ macOS 10.14.2  
_Compiler:_ Clang (Apple LLVM version 10.0.0)

* * *

I have a namespace (`AGeoUtil`) for utility functions in my library, which should works like the `TMath` namespace. But when I try to do tab completion in a ROOT session, I get the following error after typing `AGeoUtil::` and a tab.

```auto
root [0] gSystem->Load("libROBAST")
root [1] AGeoUtil::Error in <TClass::LoadClassInfo>: no interpreter information for class AGeoUtil is available even though it has a TClass initialization routine.

Error in <TClass::LoadClassInfo>: no interpreter information for class AGeoUtil is available even though it has a TClass initialization routine.

```

Here you can find my code related to this namespace.

> <https://github.com/ROBAST/ROBAST/blob/master/include/LinkDef.h>

  

> <https://github.com/ROBAST/ROBAST/blob/master/include/AGeoUtil.h>

  

> <https://github.com/ROBAST/ROBAST/blob/master/src/AGeoUtil.cxx>

How can I get rid of this error?

I copied some lines from the `TMath` related files but it seems that my code above are not written properly, resulting in the error.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 20, 2019, 10:10am UTC](https://root-forum.cern.ch/t/namespace-in-my-own-library/32365/2 "2019-01-20T10:10:44Z")

</div>

[Try](https://root-forum.cern.ch/t/root-6-cling-rootcling-replacements-for-cint-makecint-and-aclic-macros/27698):

```auto
#if defined( __MAKECINT__ ) || defined( __ROOTCLING__ )

#pragma link C++ nestedclass;
#pragma link C++ nestedtypedef;

#pragma link C++ namespace AGeoUtil;
#pragma link C++ defined_in namespace AGeoUtil;

#pragma link C++ function AGeoUtil::MakePointToPointBBox(const char*, const TVector3&, const TVector3&, Double_t, Double_t, TGeoBBox **, TGeoCombiTrans** );
#pragma link C++ function AGeoUtil::MakePointToPointTube(const char*, const TVector3&, const TVector3&, Double_t, TGeoTube **, TGeoCombiTrans** );

#endif /* defined( __MAKECINT__ ) || defined( __ROOTCLING__ ) */

```

BTW. I think you could completely remove: `NamespaceImp(AGeoUtil)`

---

<div class="post-metadata">

**Author:** ![oxon](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oxon/32/12641_2.png) [@oxon](https://root-forum.cern.ch/u/oxon)\
**Post date:** [January 20, 2019, 1:40pm UTC](https://root-forum.cern.ch/t/namespace-in-my-own-library/32365/3 "2019-01-20T13:40:10Z")

</div>

Thank you. But I still get the same error with the following `LinkDef.h`.

```auto
#if defined( __MAKECINT__ )

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ nestedclass;
#pragma link C++ nestedtypedef;

#pragma link C++ namespace AGeoUtil;
#pragma link C++ defined_in namespace AGeoUtil;

#pragma link C++ function AGeoUtil::MakePointToPointBBox(const char*, const TVector3&, const TVector3&, Double_t, Double_t, TGeoBBox **, TGeoCombiTrans** );
#pragma link C++ function AGeoUtil::MakePointToPointTube(const char*, const TVector3&, const TVector3&, Double_t, TGeoTube **, TGeoCombiTrans** );

#pragma link C++ class ABorderSurfaceCondition;
#pragma link C++ class ACauchyFormula;
#pragma link C++ class ACorsikaIACTEventHeader;
#pragma link C++ class ACorsikaIACTFile;
#pragma link C++ class ACorsikaIACTRunHeader;
#pragma link C++ class AFocalSurface;
#pragma link C++ class AGeoAsphericDisk;
#pragma link C++ class AGeoBezierPcon;
#pragma link C++ class AGeoBezierPgon;
#pragma link C++ class AGeoWinstonCone2D;
#pragma link C++ class AGeoWinstonConePoly;
#pragma link C++ class AGlassCatalog;
#pragma link C++ class ALens;
#pragma link C++ class AMirror;
#pragma link C++ class AObscuration;
#pragma link C++ class AOpticalComponent;
#pragma link C++ class AOpticsManager;
#pragma link C++ class ARay;
#pragma link C++ class ARayArray;
#pragma link C++ class ARayShooter;
#pragma link C++ class ARefractiveIndex;
#pragma link C++ class ARefractiveIndexDotInfo;
#pragma link C++ class ASchottFormula;
#pragma link C++ class ASellmeierFormula;

// for automatic loading
#ifdef MAKE_MAPS
#pragma link C++ class AGeoUtil;
#endif

#endif

```

> BTW. I think you could completely remove: `NamespaceImp(AGeoUtil)`

This is for old ROOT5 compatibility, because `TMath.cxx` says

```auto
 // Without this macro the THtml doc for TMath can not be generated

```

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 20, 2019, 3:29pm UTC](https://root-forum.cern.ch/t/namespace-in-my-own-library/32365/4 "2019-01-20T15:29:06Z")

</div>

It seems there is some ROOT 6 problem with the “namespace AGeoUtil” (works fine in ROOT 5). I guess @axel could have a look at your [Makefile](https://github.com/ROBAST/ROBAST/blob/master/Makefile) and fix it (I suspect some “rootcling” versus “rootcint” incompatibility).

---

<div class="post-metadata">

**Author:** ![oxon](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oxon/32/12641_2.png) [@oxon](https://root-forum.cern.ch/u/oxon)\
**Post date:** [January 20, 2019, 3:45pm UTC](https://root-forum.cern.ch/t/namespace-in-my-own-library/32365/5 "2019-01-20T15:45:07Z")

</div>

Now I understand that this is not due to my `LinkDef.h` but due to this automatic loading issue.

> [@"error: unknown type name" in](https://root-forum.cern.ch/t/error-unknown-type-name-in/31980):
>
> ROOT Version: 6.14/06 Platform: macOS 10.14.1 and CentOS 7 Compiler: Clang or GCC When I execute a very simple script which uses one of the classes of my own library, I get the following error in the second execution time. $ root root [0] .x test.C Info in \<TGeoManager::TGeoManager\>: Geometry manager, manager created root [1] .x test.C In file included from input\_line\_27:1: /Users/oxon/ROBAST/test.C:4:3: error: unknown type name 'AOpticsManager' AOpticsManager\* manager = new AOpticsManag…

To make the tab completion works and to allow the user to use the methods inside the user’s namespace, the header file needs to be `#include`d first.

```auto
root [0] gSystem->Load("libROBAST")

root [2] #include "AGeoUtil.h"
root [3] AGeoUtil::

```

works fine.

@axel, would you tell me the issue page of this ROOT-6 loading issue if it exists?

---

<div class="post-metadata">

**Author:** ![oxon](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oxon/32/12641_2.png) [@oxon](https://root-forum.cern.ch/u/oxon)\
**Post date:** [January 20, 2019, 3:50pm UTC](https://root-forum.cern.ch/t/namespace-in-my-own-library/32365/6 "2019-01-20T15:50:31Z")

</div>

Sorry I found the issue report myself from the thread I linked.  
[https://sft.its.cern.ch/jira/browse/ROOT-8745](https://sft.its.cern.ch/jira/browse/ROOT-8745)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 20, 2019, 3:53pm UTC](https://root-forum.cern.ch/t/namespace-in-my-own-library/32365/7 "2019-01-20T15:53:23Z")

</div>

@axel Well, I thought one would not need to `#include "AGeoUtil.h"` when the library has the “.pcm” file generated by “rootcling”.

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [January 22, 2019, 8:32am UTC](https://root-forum.cern.ch/t/namespace-in-my-own-library/32365/8 "2019-01-22T08:32:50Z")

</div>

We cannot autoload nor autoparse functions. The usual workaround is to declare a class inside the namespace `AGeoUtil` and create a `#pragma link C++ class` statement for that.

This will be fixed by C++ modules; the upcoming v6.16 will be a preview release for those (i.e. they are coming!)

Cheers, Axel.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [February 5, 2019, 8:32am UTC](https://root-forum.cern.ch/t/namespace-in-my-own-library/32365/9 "2019-02-05T08:32:50Z")

</div>

Closed on February 5, 2019, 8:32am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
