opencensus-cpp icon indicating copy to clipboard operation
opencensus-cpp copied to clipboard

GCC build error

Open taekahn opened this issue 2 years ago • 0 comments

When compiling under GCC 11.2.0 with -std=c++20 the following line causes an error.

https://github.com/census-instrumentation/opencensus-cpp/blob/afe0460f92fb78e6d6cf8c8a30ced9bc5e2e57d3/opencensus/common/internal/stats_object.h#L81

The specific error:

external/io_opencensus_cpp/opencensus/common/internal/stats_object.h:81:26: error: expected ')' before 'num_stats'
81 |   StatsObject<N>(uint16_t num_stats, absl::Duration interval, absl::Time now);
|                 ~        ^~~~~~~~~~
|                          )

What i believe is the cause of the error: StatsObject<N> I've never seen anyone repeat the template parameter in the declaration of the constructor like this before and believe this to be a syntax error that was previously not being caught by GCC.

-       StatsObject<N>(uint16_t num_stats, absl::Duration interval, absl::Time now);
+       StatsObject(uint16_t num_stats, absl::Duration interval, absl::Time now);

The above change solves the build issue for me.

Created a patch https://github.com/census-instrumentation/opencensus-cpp/pull/466

taekahn avatar Mar 28 '22 21:03 taekahn