Skip to content

Commit e5bcf24

Browse files
simiaEugene Ostroukhov
authored andcommitted
Protect grpc generated sources from unwanted system macros (grpc#39266)
grpc#38474 added protection from unwanted macros to the header files. This PR adds the same protection to the source files. Without protection both in header and source files the code containing system macros will not compile. Macros will apply to function names in cc files and those will start to differ from the ones in header files. This solves issues like described here: conda-forge/google-cloud-cpp-feedstock#196 Closes grpc#39266 COPYBARA_INTEGRATE_REVIEW=grpc#39266 from simia:protect_cc_files 3323fba PiperOrigin-RevId: 751501020
1 parent 96bb185 commit e5bcf24

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/compiler/cpp_generator.cc

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,20 +1744,15 @@ std::string GetSourceIncludes(grpc_generator::File* file,
17441744
auto printer = file->CreatePrinter(&output);
17451745
std::map<std::string, std::string> vars;
17461746
static const char* headers_strs[] = {
1747-
"functional",
1748-
"grpcpp/support/async_stream.h",
1749-
"grpcpp/support/async_unary_call.h",
1750-
"grpcpp/impl/channel_interface.h",
1751-
"grpcpp/impl/client_unary_call.h",
1752-
"grpcpp/support/client_callback.h",
1753-
"grpcpp/support/message_allocator.h",
1754-
"grpcpp/support/method_handler.h",
1755-
"grpcpp/impl/rpc_service_method.h",
1756-
"grpcpp/support/server_callback.h",
1757-
"grpcpp/impl/server_callback_handlers.h",
1758-
"grpcpp/server_context.h",
1759-
"grpcpp/impl/service_type.h",
1760-
"grpcpp/support/sync_stream.h"};
1747+
"functional", "grpcpp/support/async_stream.h",
1748+
"grpcpp/support/async_unary_call.h", "grpcpp/impl/channel_interface.h",
1749+
"grpcpp/impl/client_unary_call.h", "grpcpp/support/client_callback.h",
1750+
"grpcpp/support/message_allocator.h", "grpcpp/support/method_handler.h",
1751+
"grpcpp/impl/rpc_service_method.h", "grpcpp/support/server_callback.h",
1752+
"grpcpp/impl/server_callback_handlers.h", "grpcpp/server_context.h",
1753+
"grpcpp/impl/service_type.h", "grpcpp/support/sync_stream.h",
1754+
// ports_def.inc Must be included as last
1755+
"grpcpp/ports_def.inc"};
17611756
std::vector<std::string> headers(headers_strs, array_end(headers_strs));
17621757
PrintIncludes(printer.get(), headers, params.use_system_headers,
17631758
params.grpc_search_path);
@@ -2253,6 +2248,8 @@ std::string GetSourceEpilogue(grpc_generator::File* file,
22532248
temp.append(*part);
22542249
temp.append("\n");
22552250
}
2251+
// Must be included at end of file
2252+
temp.append("#include <grpcpp/ports_undef.inc>\n");
22562253
temp.append("\n");
22572254
}
22582255

0 commit comments

Comments
 (0)