You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让Autotools将.r文件识别为C头文件而非Ratfor源文件?

Fixing Autotools Treating .r Files as Ratfor Instead of C Headers

Got it, let's tackle this issue head-on. The core problem here is that Autotools has a default rule where .r files get flagged as Ratfor source code (a vintage Fortran preprocessing language)—that's why it's panicking about needing an F77 compiler, even though your .r files are just C headers for information hiding. Here are two solid ways to fix this:

Method 1: Disable Ratfor Detection in configure.ac

Autoconf uses an internal macro _AC_F77_RATFOR to handle Ratfor file associations. We can explicitly block this macro to break that default link:

  1. Open your configure.ac file in a text editor.
  2. Add this line somewhere after AC_INIT and before any Fortran-related checks (like if you had AC_PROG_F77 defined):
    # Prevent Autoconf from treating .r files as Ratfor source
    m4_pattern_forbid([_AC_F77_RATFOR])
    
  3. Save the file, then re-run autoreconf -iv. This tells Autotools to completely ignore the Ratfor association, so it won't hunt for an F77 compiler anymore.

Method 2: Explicitly Mark .r Files as C Headers in Makefile.am

If you want to leave no room for ambiguity, you can directly tell Automake that these .r files are headers (not code to compile):

  1. Open your Makefile.am file.
  2. Add a line to include all .r files in your project's header list:
    # Treat .r files as C headers for information hiding
    HEADERS += $(wildcard *.r)
    
    If you only have specific .r files, list them directly instead of using wildcard, e.g.:
    HEADERS += object.r container.r
    
  3. This signals to Automake that these files are meant to be included via #include "file.r" in your C code, so it won't attempt to compile them with a Fortran toolchain.

Either method should resolve the error. If you want to be extra thorough, you can use both together—they don't conflict at all.

内容的提问来源于stack exchange,提问作者guus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:17:00