Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error when using TIMED_FUNC inside method called by multiple threads #853

Open
davidelahoz opened this issue May 8, 2024 · 0 comments

Comments

@davidelahoz
Copy link

I'm trying to use easyloggingpp for tracking the performance of a computation intensive method called from multiple theads. In order to achieve that, this method starts by calling TIMED_FUNC(timerObj); as shown bellow:

void class::intensiveMethod(){
   TIMED_FUNC(timerObj);
   // Some calculations...
}

Easyloggingpp is initialized with the following macros defined:

#define ELPP_FEATURE_ALL
#define ELPP_THREAD_SAFE
#define ELPP_FORCE_USE_STD_THREAD
INITIALIZE_EASYLOGGINGPP

As a result, compiler fails and shows this error:
``

/tmp/build-via-sdist-dtgmx5ps/example/src/example.cpp:57:5: error: invalid use of incomplete type ‘class el::base::PerformanceTracker’
   57 |     TIMED_FUNC(timerObj);
      |     ^~~~~~~~~~
In file included from /tmp/build-via-sdist-dtgmx5ps/example/src/example.cpp:1:
/config/.conan2/p/b/easyl65a687b0e9e22/p/include/easylogging++.h:484:7: note: forward declaration of ‘class el::base::PerformanceTracker’
  484 | class PerformanceTracker;
      |       ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/locale_conv.h:41,
                 from /usr/include/c++/11/locale:43,
                 from /usr/include/c++/11/bits/fs_path.h:37,
                 from /usr/include/c++/11/filesystem:45,
                 ...
                 from /tmp/build-via-sdist-dtgmx5ps/example/src/example.cpp:1:
/usr/include/c++/11/bits/unique_ptr.h: In instantiation of ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = el::base::PerformanceTracker]’:
/usr/include/c++/11/bits/unique_ptr.h:361:17:   required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = el::base::PerformanceTracker; _Dp = std::default_delete<el::base::PerformanceTracker>]’
/tmp/build-via-sdist-dtgmx5ps/example/src/example.cpp:57:5:   required from here
/usr/include/c++/11/bits/unique_ptr.h:83:23: error: invalid application of ‘sizeof’ to incomplete type ‘el::base::PerformanceTracker’
   83 |         static_assert(sizeof(_Tp)>0,
      |                       ^~~~~~~~~~~

If I comment TIMED_FUNC(timerObj);, the program compiles fine.

Does performance tracking require defining additional macros or creating timerObj as a global variable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant