diff --git a/ruby/ext/google/protobuf_c/extconf.rb b/ruby/ext/google/protobuf_c/extconf.rb index f97b9b5b25..5a63119e02 100755 --- a/ruby/ext/google/protobuf_c/extconf.rb +++ b/ruby/ext/google/protobuf_c/extconf.rb @@ -22,7 +22,12 @@ debug_enabled = ENV["PROTOBUF_CONFIG"] == "dbg" additional_c_flags = debug_enabled ? "-O0 -fno-omit-frame-pointer -fvisibility=default -g" : "-O3 -DNDEBUG -fvisibility=hidden" -if RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/ || RUBY_PLATFORM =~ /freebsd/ +if RUBY_PLATFORM =~ /mswin/ + # cl.exe does not understand GCC-style flags. C11 or later is required + # for _Generic, which the upb MSVC atomics fall back on. c17 is the + # highest C standard mode cl.exe supports. + $CFLAGS += debug_enabled ? " -std:c17 -Od" : " -std:c17 -DNDEBUG" +elsif RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/ || RUBY_PLATFORM =~ /freebsd/ $CFLAGS += " -std=gnu99 -Wall -Wsign-compare -Wno-declaration-after-statement #{additional_c_flags}" else $CFLAGS += " -std=gnu99 #{additional_c_flags}" diff --git a/ruby/ext/google/protobuf_c/protobuf.c b/ruby/ext/google/protobuf_c/protobuf.c index aff8fab38a..5c8f046d3c 100644 --- a/ruby/ext/google/protobuf_c/protobuf.c +++ b/ruby/ext/google/protobuf_c/protobuf.c @@ -379,7 +379,7 @@ static VALUE Google_Protobuf_Internal_allocation_count_fail_on(VALUE self, // This must be named "Init_protobuf_c" because the Ruby module is named // "protobuf_c" -- the VM looks for this symbol in our .so. -__attribute__((visibility("default"))) void Init_protobuf_c() { +RUBY_FUNC_EXPORTED void Init_protobuf_c() { VALUE google = rb_define_module("Google"); VALUE protobuf = rb_define_module_under(google, "Protobuf");