# R\_\_LOCKGUARD2(gErrorMutex) compatibility to ROOT v6.26

**URL:** <https://root-forum.cern.ch/t/r-lockguard2-gerrormutex-compatibility-to-root-v6-26/49119>\
**Category:** Newbie\
**Created:** [March 10, 2022, 3:50pm UTC](https://root-forum.cern.ch/t/r-lockguard2-gerrormutex-compatibility-to-root-v6-26/49119 "2022-03-10T15:50:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonio.iuliano2](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/antonio.iuliano2/32/24948_2.png) [@antonio.iuliano2](https://root-forum.cern.ch/u/antonio.iuliano2)\
**Post date:** [March 10, 2022, 3:50pm UTC](https://root-forum.cern.ch/t/r-lockguard2-gerrormutex-compatibility-to-root-v6-26/49119/1 "2022-03-10T15:50:31Z")

</div>

\_ROOT Version:6.26  
\_Platform: CENTOS7 (lxplus)  
_Compiler:_ Not Provided

Dear ROOT experts,

I have a compatibility issue. A log library I use in my laboratory software uses the following line:

```auto
R__LOCKGUARD2(gErrorMutex);

```

Which does not compile anymore with ROOT 6.26 with following error:  
EdbLog.cxx:91:17: error: ‘gErrorMutex’ was not declared in this scope

I was able to understand the reason, by backtracking to ROOT 6.24 and calling gErrorMutex:

```auto
ROOT_prompt_0:1:1: warning: 'gErrorMutex' is deprecated: will be removed in ROOT v6.26: ROOT stopped exporting gErrorMutex. [-Wdeprecated-declarations]

```

This variable is not exported anymore, so how should I replace this line of code to make it work correctly in ROOT v6.26?  
I think I should then define a similar TVirtualMutex\* pointer myself and replace this call to it, but how was gErrorMutex built?

Best regards,  
Antonio Iuliano

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [March 10, 2022, 4:08pm UTC](https://root-forum.cern.ch/t/r-lockguard2-gerrormutex-compatibility-to-root-v6-26/49119/2 "2022-03-10T16:08:27Z")

</div>

Maybe @Axel knows how to solve this issue

---

<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:** [March 10, 2022, 5:13pm UTC](https://root-forum.cern.ch/t/r-lockguard2-gerrormutex-compatibility-to-root-v6-26/49119/3 "2022-03-10T17:13:10Z")

</div>

We actually need @pcanal here 🙂

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [March 10, 2022, 8:02pm UTC](https://root-forum.cern.ch/t/r-lockguard2-gerrormutex-compatibility-to-root-v6-26/49119/4 "2022-03-10T20:02:07Z")

</div>

Do you remember why you elect to use `gErrorMutex` originally?

If you need to lock the ROOT internal while doing your logging you can use

```auto
R__LOCKGUARD(gROOTMutex);

```

If you just need to lock a section of your logger (and that section does not use anything ROOT related), then we recommend that you use `std::mutex` and `std::lock_guard`.

Cheers,  
Philippe.

> I think I should then define a similar TVirtualMutex\* pointer myself and replace this call to it, but how was gErrorMutex built?

That would work do. Initialize the pointer to `nullptr` and `R__LOCKGUARD2` will create the mutex as needed.

---

<div class="post-metadata">

**Author:** ![antonio.iuliano2](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/antonio.iuliano2/32/24948_2.png) [@antonio.iuliano2](https://root-forum.cern.ch/u/antonio.iuliano2)\
**Post date:** [March 11, 2022, 6:11pm UTC](https://root-forum.cern.ch/t/r-lockguard2-gerrormutex-compatibility-to-root-v6-26/49119/5 "2022-03-11T18:11:54Z")

</div>

Dear Philippe,

Thank you very much for your advice.  
I have checked that gGlobalMutex also works:

```auto
R__LOCKGUARD2(gGlobalMutex);

```

Best regards,  
Antonio Iuliano
