Feature #4924

mkmf have_header fails with C++ headers

Added by Michael Edgar almost 3 years ago. Updated over 1 year ago.

[ruby-core:37337]
Status:Assigned
Priority:Low
Assignee:Nobuyoshi Nakada
Category:-
Target version:next minor

Description

=begin
When a user calls (({haveheader('somecpp_header.h')})), and then header includes a line such as(({ #include })), mkmf will fail.

An example run follows:

  • extconf.rb

    require 'mkmf'
    havelibrary('stdc++')
    have
    header('BasicBlock.h')
    create_makefile('laser/BasicBlock')

  • mkmf.log
    have_header: checking for BasicBlock.h... -------------------- no

    "gcc -E -I/Users/michaeledgar/.rvm/rubies/ruby-1.9.2-head/include/ruby-1.9.1/x8664-darwin10.7.0 -I/Users/michaeledgar/.rvm/rubies/ruby-1.9.2-head/include/ruby-1.9.1/ruby/backward -I/Users/michaeledgar/.rvm/rubies/ruby-1.9.2-head/include/ruby-1.9.1 -I. -DXOPENSOURCE -DDARWINCSOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe conftest.c -o conftest.i"
    In file included from conftest.c:3:
    ./BasicBlock.h:4:18: error: vector: No such file or directory
    ./BasicBlock.h:5:21: error: exception: No such file or directory
    ./BasicBlock.h:6:21: error: stdexcept: No such file or directory
    checked program was:
    /* begin /
    1: #include "ruby.h"
    2:
    3: #include
    /
    end */

The issue here is that the temporary file created to perform the header test is ((%conftest.c%)), not ((%conftest.cc%)) or ((%conftest.cpp%)). Changing the
name of the file and re-running gcc gives success.

In ((%mkmf.rb%)), haveheader executes cppcommand, which creates the shell command to run. However, cppcommand uses the constant (({CONFTESTC = "conftest.c"})). It should use a new constant, (({CONFTEST_CPP = "conftest.cc"})).

I've attached a patch that does this as expected. Tests pass; I'm unsure precisely how to construct
a test case that would be appropriate for the Ruby trunk. There are very few guiding examples in the
existing test suite.


Related issues

Related to ruby-trunk - Feature #3330: mkmf (find|have)_cxx_header Rejected

History

#1 Updated by Nobuyoshi Nakada almost 3 years ago

  • Tracker changed from Bug to Feature
  • Priority changed from Normal to Low

#2 Updated by Yusuke Endoh about 2 years ago

  • Status changed from Open to Assigned
  • Assignee set to Nobuyoshi Nakada

#3 Updated by Yusuke Endoh over 1 year ago

  • Target version set to next minor

Also available in: Atom PDF