2017-06-22 24 views
0

私は、ヘッダファイルrose.hの存在を確認する必要があるという問題があります。 AC_CHECK_HEADERを使用すると、一連のその他のヘッダーの後ろにヘッダーが含まれます。 このようなヘッダーの1つはsys/stat.hです。 残念ながら、(私はどのような方法で、何の制御をオーバーしていない)rose.hヘッダファイル stat.hヘッダが含まれている/ 前のsys含まれている必要がありますAC_CHECK_HEADERでのインクルードの順序変更

#if defined(_SYS_STAT_H) 
#error "sys/stat.h should not have been included before the _FILE_OFFSET_BITS macro is set! (use rose.h first...)" 
#endif 

これは、configureを引き起こし

checking rose.h usability... no 
checking rose.h presence... yes 
configure: WARNING: rose.h: present but cannot be compiled 
configure: WARNING: rose.h:  check for missing prerequisite headers? 
configure: WARNING: rose.h: see the Autoconf documentation 
configure: WARNING: rose.h:  section "Present But Cannot Be Compiled" 
configure: WARNING: rose.h: proceeding with the compiler's result 
checking for rose.h... no 
configure: error: A Working Rose installation is required. (Missing rose.h.) 

質問:SYS/stat.hのために含ま緩く前rose.hために含めるを作成するためにAC_CHECK_HEADERを伝える方法はありますをエラーするためのスクリプト?

問題のautoconfのの経典:

AC_CHECK_HEADERS(
    [rose.h], 
    [], 
    [AC_MSG_ERROR(A Working Rose installation is required. (Missing rose.h.))] 
) 

関連のあるconfig.logの出力:マクロAC_SYS_LARGEFILEAC_CHECK_HEADER前に解決することがあり、彼らは根本的な問題を呼び出す

configure:3995: $? = 0 
configure:4013: result: yes 
configure:4032: checking rose.h usability 
configure:4032: g++ -std=c++11 -c -fPIC -Wall -Wno-deprecated -Wextra -O3 -DUSE_CBC conftest.cpp >&5 
In file included from /home/username/.local/opt/rose/include/rose/sage3basic.h:38:0, 
       from /home/username/.local/opt/rose/include/rose/sage3basic.hhh:4, 
       from /home/username/.local/opt/rose/include/rose/rose.h:10, 
       from conftest.cpp:56: 
/home/username/.local/opt/rose/include/rose/fileoffsetbits.h:16:2: error: #error "sys/stat.h should not have been included before the _FILE_OFFSET_BITS macro is set! (use rose.h first...)" 
#error "sys/stat.h should not have been included before the _FILE_OFFSET_BITS macro is set! (use rose.h first...)" 
^
configure:4032: $? = 1 
configure: failed program was: 
| /* confdefs.h */ 
| #define PACKAGE_NAME "project" 
| #define PACKAGE_TARNAME "project" 
| #define PACKAGE_VERSION "version-0.1" 
| #define PACKAGE_STRING "project version-0.1" 
| #define PACKAGE_BUGREPORT "" 
| #define PACKAGE_URL "" 
| #define HAVE_CXX11 1 
| #define STDC_HEADERS 1 
| #define HAVE_SYS_TYPES_H 1 
| #define HAVE_SYS_STAT_H 1 
| #define HAVE_STDLIB_H 1 
| #define HAVE_STRING_H 1 
| #define HAVE_MEMORY_H 1 
| #define HAVE_STRINGS_H 1 
| #define HAVE_INTTYPES_H 1 
| #define HAVE_STDINT_H 1 
| #define HAVE_UNISTD_H 1 
| #define HAVE_ISL_VERSION_H 1 
| #define HAVE_LINEAR_SOLVER_LINEAR_SOLVER_H 1 
| #define HAVE_LIBORTOOLS 1 
| /* end confdefs.h. */ 
| #include <stdio.h> 
| #ifdef HAVE_SYS_TYPES_H 
| # include <sys/types.h> 
| #endif 
| #ifdef HAVE_SYS_STAT_H 
| # include <sys/stat.h> 
| #endif 
| #ifdef STDC_HEADERS 
| # include <stdlib.h> 
| # include <stddef.h> 
| #else 
| # ifdef HAVE_STDLIB_H 
| # include <stdlib.h> 
| # endif 
| #endif 
| #ifdef HAVE_STRING_H 
| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H 
| # include <memory.h> 
| # endif 
| # include <string.h> 
| #endif 
| #ifdef HAVE_STRINGS_H 
| # include <strings.h> 
| #endif 
| #ifdef HAVE_INTTYPES_H 
| # include <inttypes.h> 
| #endif 
| #ifdef HAVE_STDINT_H 
| # include <stdint.h> 
| #endif 
| #ifdef HAVE_UNISTD_H 
| # include <unistd.h> 
| #endif 
| #include <rose.h> 
configure:4032: result: no 
configure:4032: checking rose.h presence 
configure:4032: g++ -std=c++11 -E conftest.cpp 
configure:4032: $? = 0 
configure:4032: result: yes 
configure:4032: WARNING: rose.h: present but cannot be compiled 
configure:4032: WARNING: rose.h:  check for missing prerequisite headers? 
configure:4032: WARNING: rose.h: see the Autoconf documentation 
configure:4032: WARNING: rose.h:  section "Present But Cannot Be Compiled" 
configure:4032: WARNING: rose.h: proceeding with the compiler's result 
configure:4032: checking for rose.h 
configure:4032: result: no 
configure:4039: error: A Working Rose installation is required. (Missing rose.h.) 

## ---------------- ## 
## Cache variables. ## 
## ---------------- ## 

ac_cv_cxx_compiler_gnu=yes 
ac_cv_env_CCC_set= 
ac_cv_env_CCC_value= 
ac_cv_env_CPPFLAGS_set= 
ac_cv_env_CPPFLAGS_value= 
ac_cv_env_CXXCPP_set= 
ac_cv_env_CXXCPP_value= 
ac_cv_env_CXXFLAGS_set= 
ac_cv_env_CXXFLAGS_value= 
ac_cv_env_CXX_set= 
ac_cv_env_CXX_value= 
ac_cv_env_LDFLAGS_set= 
ac_cv_env_LDFLAGS_value= 
ac_cv_env_LIBS_set= 
ac_cv_env_LIBS_value= 
ac_cv_env_build_alias_set= 
ac_cv_env_build_alias_value= 
ac_cv_env_host_alias_set= 
ac_cv_env_host_alias_value= 
ac_cv_env_target_alias_set= 
ac_cv_env_target_alias_value= 
ac_cv_header_inttypes_h=yes 
ac_cv_header_isl_version_h=yes 
ac_cv_header_linear_solver_linear_solver_h=yes 
ac_cv_header_memory_h=yes 
ac_cv_header_rose_h=no 
ac_cv_header_stdc=yes 
ac_cv_header_stdint_h=yes 
ac_cv_header_stdlib_h=yes 
ac_cv_header_string_h=yes 
ac_cv_header_strings_h=yes 
ac_cv_header_sys_stat_h=yes 
ac_cv_header_sys_types_h=yes 
ac_cv_header_unistd_h=yes 
ac_cv_lib_ortools___include__linear_solver_linear_solver_h___include__string__=yes 
ac_cv_objext=o 
ac_cv_path_EGREP='/bin/grep -E' 
ac_cv_path_GREP=/bin/grep 
ac_cv_prog_CXXCPP='g++ -std=c++11 -E' 
ac_cv_prog_ac_ct_CXX=g++ 
ac_cv_prog_cxx_g=yes 
ac_cv_search_isl_version=-lisl 
ax_cv_cxx_compile_cxx11=no 
ax_cv_cxx_compile_cxx11__std_cpp11=yes 

## ----------------- ## 
## Output variables. ## 
## ----------------- ## 

CPPFLAGS='' 
CXX='g++ -std=c++11' 
CXXCPP='g++ -std=c++11 -E' 
CXXFLAGS='-fPIC -Wall -Wno-deprecated -Wextra -O3 -DUSE_CBC' 
DEFS='' 
ECHO_C='' 
ECHO_N='-n' 
ECHO_T='' 
EGREP='/bin/grep -E' 
EXEEXT='' 
GREP='/bin/grep' 
HAVE_CXX11='1' 
LDFLAGS='' 
LIBOBJS='' 
LIBS='-lortools -lisl ' 
LTLIBOBJS='' 
OBJEXT='o' 
PACKAGE_BUGREPORT='' 
PACKAGE_NAME='project' 
PACKAGE_STRING='project version-0.1' 
PACKAGE_TARNAME='project' 
PACKAGE_URL='' 
PACKAGE_VERSION='version-0.1' 
PATH_SEPARATOR=':' 
PYTHON='' 
SHELL='/bin/bash' 
UNZIP='' 
_PYPY_maybe='' 
_PYTHON2_maybe='' 
_PYTHON_maybe='' 
_UNZIP_maybe='' 
ac_ct_CXX='g++' 
bindir='${exec_prefix}/bin' 
build_alias='' 
datadir='${datarootdir}' 
datarootdir='${prefix}/share' 
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' 
dvidir='${docdir}' 
exec_prefix='NONE' 
host_alias='' 
htmldir='${docdir}' 
includedir='${prefix}/include' 
infodir='${datarootdir}/info' 
libdir='${exec_prefix}/lib' 
libexecdir='${exec_prefix}/libexec' 
localedir='${datarootdir}/locale' 
localstatedir='${prefix}/var' 
mandir='${datarootdir}/man' 
oldincludedir='/usr/include' 
pdfdir='${docdir}' 
prefix='NONE' 
program_transform_name='s,x,x,' 
psdir='${docdir}' 
runstatedir='${localstatedir}/run' 
sbindir='${exec_prefix}/sbin' 
sharedstatedir='${prefix}/com' 
sysconfdir='${prefix}/etc' 
target_alias='' 

## ----------- ## 
## confdefs.h. ## 
## ----------- ## 

/* confdefs.h */ 
#define PACKAGE_NAME "project" 
#define PACKAGE_TARNAME "project" 
#define PACKAGE_VERSION "version-0.1" 
#define PACKAGE_STRING "project version-0.1" 
#define PACKAGE_BUGREPORT "" 
#define PACKAGE_URL "" 
#define HAVE_CXX11 1 
#define STDC_HEADERS 1 
#define HAVE_SYS_TYPES_H 1 
#define HAVE_SYS_STAT_H 1 
#define HAVE_STDLIB_H 1 
#define HAVE_STRING_H 1 
#define HAVE_MEMORY_H 1 
#define HAVE_STRINGS_H 1 
#define HAVE_INTTYPES_H 1 
#define HAVE_STDINT_H 1 
#define HAVE_UNISTD_H 1 
#define HAVE_ISL_VERSION_H 1 
#define HAVE_LINEAR_SOLVER_LINEAR_SOLVER_H 1 
#define HAVE_LIBORTOOLS 1 

configure: exit 1 
+1

'sys/stat.h'は標準ヘッダファイルです。 ***ヘッダファイルの前に***を入れる必要がある場合、その何かが根本的に何らかの方法で壊れていなければなりません。この 'rose.h 'が何をしようとしていても、それは間違っています。 –

+0

あなたはこのデザインの決定について強く感じているようです。 [Rose Compiler github](https://github.com/rose-compiler/rose)で問題を開いてください。問題のコードは[rose/src/frontend/SageIII/fileoffsetbits.h:15](https://github.com/rose-compiler/rose/blob/43c77481d0801ac122f74a778a35e2a074032d1f/src/frontend/SageIII/fileoffsetbits.h#L15)です。 )。 – memorableUserNameHere

答えて

0

もう少し詳しくはAC_CHECK_HEADERS documentationを読んで、私は少しハッキーの方法で私のためにこの仕事をすると思った。 AC_CHECK_HEADERSマクロにはオプションのincludesパラメータがあります。ここでは、テストのincludeディレクティブの前に挿入されたコード(通常はディレクティブを含みます)を記述できます。

ここでは、sys/stat.hのincludeを守るHAVE_SYS_STAT_Hシンボルを、未定義にする#undefディレクティブのような「楽しさ」の事、たくさんの書き込み、その後、デフォルトの方法に応じてAC_INCLUDES_DEFAULT

AC_CHECK_HEADERS(
    [rose.h], 
    [], 
    [AC_MSG_ERROR(A Working Rose installation is required. (Missing rose.h.))], 
    [ 
    [ #undef HAVE_SYS_STAT_H ] 
    AC_INCLUDES_DEFAULT 
    ] 
) 

をインクルードすることができます正しい/現実的なあなたのチェックをしたい、これはあなたのために動作しない可能性があります。 sys/stat.hが後でrose.hに含まれていることがわかりました。私の特定の問題を解決するためにこの解決策を見つけるのは、きわめてうまくです。

ただし、このハックを使用してインクルードを並べ替えることもできます。

AC_CHECK_HEADERS(
    [rose.h], 
    [], 
    [AC_MSG_ERROR(A Working Rose installation is required. (Missing rose.h.))], 
    [ 
    [ 
    #include <rose.h> 
    ] 
    AC_INCLUDES_DEFAULT 
    ] 
) 

または問題のマスクアウト含まれています:

AC_CHECK_HEADERS(
    [rose.h], 
    [], 
    [AC_MSG_ERROR(A Working Rose installation is required. (Missing rose.h.))], 
    [ 
    [ 
    #ifdef HAVE_SYS_STAT_H 
    # define REDEF_HAVE_SYS_STAT_H 
    # undef HAVE_SYS_STAT_H 
    #endif 
    ] 

    AC_INCLUDES_DEFAULT 

    [ 
    #include <rose.h> 

    #ifdef REDEF_HAVE_SYS_STAT_H 
    # define HAVE_SYS_STAT_H 
    #endif 
    ] 

    AC_INCLUDES_DEFAULT 
    ] 
) 

または手動ですべてがあなたの好みに合わせて必要な感じが含ま注文をデフォルトのすべてが含まれて前に最も広い意味では、テスト・ヘッダを含めることができます:

AC_CHECK_HEADERS(
    [rose.h], 
    [], 
    [AC_MSG_ERROR(A Working Rose installation is required. (Missing rose.h.))], 
    [ 
    [ 
    #include <stdio.h> 
    #ifdef HAVE_SYS_TYPES_H 
    # include <sys/types.h> 
    #endif 

    #include <rose.h> 

    #ifdef HAVE_SYS_STAT_H 
    # include <sys/stat.h> 
    #endif 
    #ifdef STDC_HEADERS 
    # include <stdlib.h> 
    # include <stddef.h> 
    #else 
    # ifdef HAVE_STDLIB_H 
    # include <stdlib.h> 
    # endif 
    #endif 
    #ifdef HAVE_STRING_H 
    # if !defined STDC_HEADERS && defined HAVE_MEMORY_H 
    # include <memory.h> 
    # endif 
    # include <string.h> 
    #endif 
    #ifdef HAVE_STRINGS_H 
    # include <strings.h> 
    #endif 
    #ifdef HAVE_INTTYPES_H 
    # include <inttypes.h> 
    #endif 
    #ifdef HAVE_STDINT_H 
    # include <stdint.h> 
    #endif 
    #ifdef HAVE_UNISTD_H 
    # include <unistd.h> 
    #endif 
    ] 
    ] 
) 
1

rose.hヘッダは、LFSパラメータを定義するように見えるが、それは、は(それらが異なるのABIを使用するように)同じバイナリの異なる翻訳単位が異なるLFS設定を使用すべきではないので、ヘッダに行われ、されるべきではありませんヘッダーはそれを正確に行うリスクがあります。

いずれにせよ、AC_SYS_LARGEFILEを使用すると、ラージファイルセットに適切なLFSパラメータが設定され、何かが含まれる前に設定され、その後#errorはトリガーされません。

+0

残念ながら、ある時刻に特定の方法でLFSパラメータが設定されていないと、エラーは発生しません。これは_SYS_STAT_Hシンボルの存在によってトリガされます。 解決策を試しても、エラーは残ります。 – memorableUserNameHere

関連する問題