We are building opentelemetry-cpp with msvc and grpc support, the recipe is failing to build. We expect that -o with_otlp_grpc=True should successfully build.
I don't know of any workarounds other than to update the recipe with:
if self.settings.compiler == "msvc":
tc.extra_cxxflags = ["/DNOMINMAX"]
I have narrowed down the issue to MSVC having preprocessor macros for MIN(a, b) and MAX(a, b) and grpc defines min() and max() functions in a class:
https://github.com/grpc/grpc/blob/master/include/grpc/event_engine/memory_request.h#L45-L46
Since this class is included and used by opentelemetry this fails to correctly interpret the header file. The following are errors caused when compiling this package with the option: -o with_otlp_grpc with msvc:
We have tested this with version 1.14.2 and 1.17.0 and the behaviour is the same
Description
We are building opentelemetry-cpp with msvc and grpc support, the recipe is failing to build. We expect that -o with_otlp_grpc=True should successfully build.
I don't know of any workarounds other than to update the recipe with:
I have narrowed down the issue to MSVC having preprocessor macros for
MIN(a, b)
andMAX(a, b)
and grpc definesmin()
andmax()
functions in a class: https://github.com/grpc/grpc/blob/master/include/grpc/event_engine/memory_request.h#L45-L46 Since this class is included and used by opentelemetry this fails to correctly interpret the header file. The following are errors caused when compiling this package with the option:-o with_otlp_grpc
with msvc:We have tested this with version 1.14.2 and 1.17.0 and the behaviour is the same
I have already fixed this in my fork
Package and Environment Details
Conan profile
Build profile: [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=14 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=193 os=Windows
Steps to reproduce
conan create recipe/opentelemetry-cpp/all -o with_otlp_grpc=True --version 1.14.2 conan create recipe/opentelemetry-cpp/all -o with_otlp_grpc=True --version 1.17.0
Logs
Click to expand log
``` otlp_grpc_exporter_options.cc .conan2\p\grpcc1fa87c503b46\p\include\grpc\event_engine\memory_request.h(46,10): warning C4003: not enough arguments for function-like macro invocation 'min' (compiling source file '../../../src/exporters/otlp/src/otlp_grpc_exporter.cc') .conan2\p\grpcc1fa87c503b46\p\include\grpc\event_engine\memory_request.h(46,10): error C2059: syntax error: ')' (compiling source file '../../../src/exporters/otlp/src/otlp_grpc_exporter.cc') .conan2\p\grpcc1fa87c503b46\p\include\grpc\event_engine\memory_request.h(46,10): error C2334: unexpected token(s) preceding ':'; skipping apparent function body (compiling source file '../../../src/exporters/otlp/src/otlp_grpc_exporter.cc') .conan2\p\grpcc1fa87c503b46\p\include\grpc\event_engine\memory_request.h(47,10): warning C4003: not enough arguments for function-like macro invocation 'max' (compiling source file '../../../src/exporters/otlp/src/otlp_grpc_exporter.cc') .conan2\p\grpcc1fa87c503b46\p\include\grpc\event_engine\memory_request.h(70,2): error C2143: syntax error: missing ')' before ';' (compiling source file '../../../src/exporters/otlp/src/otlp_grpc_exporter.cc') ... (dropped the remaining errors for brevity) opentelemetry-cpp/1.14.2: ERROR: Package '1899ae5f3cbc5da043d14ce1dd2a89e5b38f7030' build failed opentelemetry-cpp/1.14.2: WARN: Build folder C:\Users\borys\.conan2\p\b\opent383b20243a6f4\b\build ERROR: opentelemetry-cpp/1.14.2: Error in build() method, line 320 cmake.build() ConanException: Error 1 while executing```