R__LOCKGUARD2(gErrorMutex) compatibility to ROOT v6.26

_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:

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:

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

Maybe @Axel knows how to solve this issue

We actually need @pcanal here :slight_smile:

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

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.

Dear Philippe,

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

R__LOCKGUARD2(gGlobalMutex);

Best regards,
Antonio Iuliano