Method: MakeMakefile#try_compile

Defined in:
lib/mkmf.rb

#try_compile(src, opt = "", werror: nil, **opts, &b) ⇒ Object Also known as: try_header

Returns whether or not the src can be compiled as a C source. opt is passed to the C compiler as options. Note that $CFLAGS is also passed to the compiler.

If a block given, it is called with the source before compilation. You can modify the source in the block.

src

a String which contains a C source

opt

a String which contains compiler options



653
654
655
656
657
658
659
# File 'lib/mkmf.rb', line 653

def try_compile(src, opt = "", werror: nil, **opts, &b)
  opt = werror_flag(opt) if werror
  try_do(src, cc_command(opt), werror: werror, **opts, &b) and
    File.file?("#{CONFTEST}.#{$OBJEXT}")
ensure
  MakeMakefile.rm_f "#{CONFTEST}*"
end