Ruby rb_定义_模块函数未编译

Ruby rb_定义_模块函数未编译,ruby,Ruby,我正在尝试用Ruby的C API创建一个模块。这是我的代码: #include <ruby.h> VALUE TopModule; VALUE SubModule; rb_define_module("TopModule"); VALUE ruby_hello_world(VALUE self, VALUE n) { return Qnil; } void Init_hello_world(void){ rb_define_global_function("ruby_

我正在尝试用Ruby的C API创建一个模块。这是我的代码:

#include <ruby.h>

VALUE TopModule;
VALUE SubModule;

rb_define_module("TopModule");

VALUE ruby_hello_world(VALUE self, VALUE n)
{
  return Qnil;
}

void Init_hello_world(void){
  rb_define_global_function("ruby_hello_world", ruby_hello_world, 1);
}
知道我错过了什么吗

C:\_mks\RubyTool>rake compile
cd tmp/x64-mingw32/hello_world/2.6.1
C:/Ruby/bin/ruby.exe -I. ../../../../ext/hello_world/extconf.rb
cd -
cd tmp/x64-mingw32/hello_world/2.6.1
C:\Ruby\msys64\mingw64\bin\mingw32-make.exe
compiling ../../../../ext/hello_world/hello_world.c
../../../../ext/hello_world/hello_world.c:6:18: error: expected declaration specifiers or '...' before string constant
 rb_define_module("TopModule");
                  ^~~~~~~~~~~
mingw32-make: *** [Makefile:244: hello_world.o] Error 1
rake aborted!
Command failed with status (2): [C:\Ruby\msys64\mingw64\bin\mingw32-make.ex...]