wolfpld / tracy

Frame profiler
https://tracy.nereid.pl/
Other
8.67k stars 598 forks source link

Weird interaction between TRACY_MANUAL_LIFETIME and TRACY_DELAYED_INIT #698

Open SUPERCILEX opened 6 months ago

SUPERCILEX commented 6 months ago

You can't use TRACY_MANUAL_LIFETIME alone because the c functions use cpp code that only exists when both macros are set: https://github.com/wolfpld/tracy/blob/d62428c482845031e4ab633e6132dbc26cfe46ca/public/client/TracyProfiler.hpp#L51-L56

Is this intentional? If so, the c APIs should also be gated by both macros? Or maybe they should be unified?

wolfpld commented 6 months ago

I don't know, I don't use it. As far as I can remember, that was the intention of the original author (@avoroshilov). I don't think it has to be like that, but that's how it is now.

avoroshilov commented 6 months ago

I don't remember the exact details at this point, but I vaguely recollect that TRACY_MANUAL_LIFETIME is not possible without TRACY_DELAYED_INIT, i.e. manual initialization is by definition delayed (more info in the PR 74). However, I see a problem where you can enable TRACY_MANUAL_LIFETIME and get a compile error? In that case maybe the solution would be to define TRACY_DELAYED_INIT as long as TRACY_MANUAL_LIFETIME is defined.

#if defined(TRACY_MANUAL_LIFETIME) 
#  define TRACY_DELAYED_INIT
#endif
SUPERCILEX commented 6 months ago

In that case maybe the solution would be to define TRACY_DELAYED_INIT as long as TRACY_MANUAL_LIFETIME is defined.

Yeah, that's probably the best bet.