Search code examples
c++rubyg++warningsruby-c-extension

Unwanted warning message with g++


I am trying to write a c++ extension for Ruby. In addition to the main file, I have a file extconf.rb:

require "mkmf"
$libs += " -lstdc++ "
create_makefile("file_name")

and, after doing ruby extconf.rb, when I try to compile it with g++ by typing make, I get the warning:

cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++

I read that it is not harmful, but is there a way to avoid this warning? There is a person with the same problem here, but the solution cannot be found.


Solution

  • Edit the resulting Makefile created after running create_makefile and remove the -Wdeclaration-after-statement from there.