Replies: 1 comment 1 reply
-
Not sure of the error, as the CI build using gcc 4.8 works fine. Could it be the one of the gcc compile option causing the error: compilation options: -Wno-unused-local-typedefs -Wall -g -fPIC -std=c++11 -DSNAPPY -fopenmp -O0 -msse3 -mssse3 -DJSON_IS_AMALGAMATION -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DJSON_IS_AMALGAMATION |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have implemented a class called myTracer, and when I include my_tracer.h (without reference myTracer class) I got an error as follows:
In file included from ../include/opentelemetry/common/key_value_iterable.h:7:0,
from ../include/opentelemetry/common/key_value_iterable_view.h:10,
from ../include/opentelemetry/common/kv_properties.h:6,
from ../include/opentelemetry/baggage/baggage.h:8,
from ../include/opentelemetry/context/context_value.h:8,
from ../include/opentelemetry/context/context.h:7,
from ../include/opentelemetry/trace/tracer.h:6,
from my_tracer.h:3,
from *.h:22,
from .cpp:5:
../include/opentelemetry/nostd/function_ref.h:53:26: error: macro "F" requires 3 arguments, but only 1 given
return (F(callable_))(std::forward(args)...);
^
../include/opentelemetry/nostd/function_ref.h: In lambda function:
../include/opentelemetry/nostd/function_ref.h:53:53: error: expected ')' before '...' token
return (F(callable_))(std::forward(args)...);
^
../include/opentelemetry/nostd/function_ref.h:53:56: error: parameter packs not expanded with '...':
return (F(callable_))(std::forward(args)...);
^
../include/opentelemetry/nostd/function_ref.h:53:56: note: 'args'
../include/opentelemetry/nostd/function_ref.h:53:56: note: 'Args'
make: *** [.o] Error 1
compilation options: -Wno-unused-local-typedefs -Wall -g -fPIC -std=c++11 -DSNAPPY -fopenmp -O0 -msse3 -mssse3 -DJSON_IS_AMALGAMATION -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DJSON_IS_AMALGAMATION
gcc verion: 4.8.3
opentelemetry-cpp verion: v1.1.0 (include api/include/opentelemetry directory now)
and my code:
my_tracer.cpp
#include "opentelemetry/context/propagation/global_propagator.h"
#include "opentelemetry/trace/provider.h"
#include "tracer_common.h"
#include "my_tracer.h"
using namespace OPENTELEMETRY_NAMESPACE;
namespace my_namespace {
void myTracer::init(void)
{
// set global propagator
context::propagation::GlobalTextMapPropagator::SetGlobalPropagator(
nostd::shared_ptrcontext::propagation::TextMapPropagator(new trace::propagation::HttpTraceContext()));
}
nostd::shared_ptrtrace::Tracer myTracer::get_tracer(std::string tracer_name)
{
auto provider = trace::Provider::GetTracerProvider();
return provider->GetTracer(tracer_name);
}
nostd::shared_ptrtrace::Span myTracer::startSpan(std::map<std::string, std::string> &trace) {
trace::StartSpanOptions options;
options.kind = trace::SpanKind::kServer; // server
std::string span_name = "";
}
void myTracer::endSpan(nostd::shared_ptrtrace::Span span) {
if (span != nullptr) {
span->End();
}
}
}
my_tracer.h
#pragma once
#include "opentelemetry/trace/tracer.h"
#include
using namespace OPENTELEMETRY_NAMESPACE;
namespace my_namespace {
class myTracer {
public:
void init(void);
nostd::shared_ptrtrace::Tracer get_tracer(std::string tracer_name);
nostd::shared_ptrtrace::Span startSpan(std::map<std::string, std::string> &trace);
void endSpan(nostd::shared_ptrtrace::Span span);
};
}
tracer_common.h
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/trace/propagation/http_trace_context.h"
using namespace OPENTELEMETRY_NAMESPACE;
namespace my_namespace {
template
class HttpTextMapCarrier : public context::propagation::TextMapCarrier {
public:
HttpTextMapCarrier(T &headers) : headers_(headers) {}
HttpTextMapCarrier() = default;
};
} // namespace
I attempt to write a snippet to test my code (include my_tracer.h, reference class and call class member functions), it worked with no error (the code is at the end). I still comfused with the previous error which is reported in function_ref.h. Does anyone know how to solve this error?
my test code, it worked
compilation options: gcc -g -lstdc++ -std=c++11 -pthread -Wl,--no-as-needed my_tracer.cpp main.cpp -I ../../include -o test
with the same gcc and opentelemetry-cpp verions
main.cpp
#include "my_tracer.h"
using namespace OPENTELEMETRY_NAMESPACE;
using namespace my_namespace;
int main(void) {
myTracer tracer;
tracer.init();
std::map<std::string, std::string> map;
map.insert(std::make_pair("traceParent", ""));
auto span = tracer.startSpan(map);
tracer.endSpan(span);
return 0;
}
Beta Was this translation helpful? Give feedback.
All reactions