wolfpld / tracy

Frame profiler
https://tracy.nereid.pl/
Other
9.94k stars 657 forks source link

error: redeclaration of ‘tracy::ScopedZone ___tracy_scoped_zone’ #580

Open Rakeki opened 1 year ago

Rakeki commented 1 year ago

Here is my implementation,

`#include

include "tracy/Tracy.hpp"

int main() { ZoneScoped; std::cout << "Hello, Tracy!" << std::endl;

// Simulating some workload
ZoneScopedN("Workload");
for (int i = 0; i < 1000000; ++i)
{
    ZoneScopedN("Iteration");
    std::cout << i << std::endl;
    // Do some work
}

return 0;

}`

Here is the error im seeing

error: redeclaration of ‘tracy::ScopedZone ___tracy_scoped_zone’ 143 | #define ZoneScopedN( name ) ZoneNamedN( ___tracy_scoped_zone, name, true ) | ^~~~~~~~~~~~~~~~~~~~ /home/pc/proj/tracy/tracy/Tracy.hpp:134:216: note: in definition of macro ‘ZoneNamedN’ 134 | # define ZoneNamedN( varname, name, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,TracyLine) { name, TracyFunction, TracyFile, (uint32_t)TracyLine, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,TracyLine), active ) | ^~~~~~~ /home/pc/proj/src/main.cpp:11:5: note: in expansion of macro ‘ZoneScopedN’ 11 | ZoneScopedN("Workload"); | ^~~~~~~~~~~ /home/pc/proj/tracy/tracy/Tracy.hpp:142:31: note: ‘tracy::ScopedZone ___tracy_scoped_zone’ previously declared here 142 | #define ZoneScoped ZoneNamed( ___tracy_scoped_zone, true ) | ^~~~~~~~~~~~~~~~~~~~ /home/pc/proj/tracy/tracy/Tracy.hpp:133:212: note: in definition of macro ‘ZoneNamed’ 133 | # define ZoneNamed( varname, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,TracyLine) { nullptr, TracyFunction, TracyFile, (uint32_t)TracyLine, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,TracyLine), active ) | ^~~~~~~ /home/pc/proj/src/main.cpp:7:5: note: in expansion of macro ‘ZoneScoped’ 7 | ZoneScoped;

gan74 commented 1 year ago

You can work around this by using ZoneNamed and ZoneNamedN. These takes an additional parameter which specifies the variable name used for the scope guard (why for ZoneScoped is always ___tracy_scoped_zone).