-
Notifications
You must be signed in to change notification settings - Fork 437
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
Compile errors appear when i import api/opentelemetry/logs/logger.h #1590
Comments
Please check the project code, and any file included before If such macro is present, it will confuse the compiler when reading the |
You may try to wrapper pragma push_macro/pop_macro when including logs headers if your project has define #pragma push_macro("Log")
#ifdef Log
#undef Log
#endif
#include < api/opentelemetry/logs/logger.h>
#pragma pop_macro("Log") |
Not directly related to this issue, but with the recent changes in the Logs API (open-telemetry/opentelemetry-specification#2676), and potentially in Logs SDK ( open-telemetry/opentelemetry-specification#2768), we may want to change the method name to Logger::Emit() for both Logs and Events. Closing this issue, as this seems to be macro with same name. |
As the names like #ifdef Log
#error macro Log is defined outside of opentelemetry, please consider rename it or wrap opentelemetry/logger.h with push_macro/pop_macro
#endif |
Non capitalized macros are always evil and should be avoided for errors like above. I don't think we should handle these validations in opentelemetry. |
I import opentelemetry-cpp with tag 1.5.0 in my project by bazel. My environment is centos7 with gcc 8.4.0.
if i include api/opentelemetry/logs/logger.h file and donot do anything else, the error appears
bazel-out/k8-fastbuild/bin/external/io_opentelemetry_cpp/api/_virtual_includes/api/opentelemetry/logs/logger.h:167:57: error: macro "Log" requires 4 arguments, but only 2 given
void Log(Severity severity, nostd::string_view message) noexcept
^
bazel-out/k8-fastbuild/bin/external/io_opentelemetry_cpp/api/_virtual_includes/api/opentelemetry/logs/logger.h:185:50: error: macro "Log" requires 4 arguments, but only 2 given
void Log(Severity severity, const T &attributes) noexcept
^
bazel-out/k8-fastbuild/bin/external/io_opentelemetry_cpp/api/_virtual_includes/api/opentelemetry/logs/logger.h:235:73: error: macro "Log" requires 4 arguments, but only 2 given
void Log(Severity severity, const common::KeyValueIterable &attributes) noexcept
^
bazel-out/k8-fastbuild/bin/external/io_opentelemetry_cpp/api/_virtual_includes/api/opentelemetry/logs/logger.h: In member function 'void opentelemetry::v1::logs::Logger::Trace(const T&)':
bazel-out/k8-fastbuild/bin/external/io_opentelemetry_cpp/api/_virtual_includes/api/opentelemetry/logs/logger.h:281:11: error: 'class opentelemetry::v1::logs::Logger' has no member named 'Log'; did you mean 'OI_Log'?
this->Log(Severity::kTrace, attributes);
^~~
OI_Log
The text was updated successfully, but these errors were encountered: