Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8585669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:07:26+00:00 2026-06-11T22:07:26+00:00

When AC_CHECK_HEADERS is invoked inside m4_foreach_w, autoheader(2.65) seems to generate a bogus template. For

  • 0

When AC_CHECK_HEADERS is invoked inside m4_foreach_w, autoheader(2.65) seems to generate a bogus template. For example:

m4_foreach_w([hdr],[[foo.h] [bar.h]],
    [AC_DEFINE([HAVE_]m4_translit(m4_toupper(hdr),[/.],[__]),[1],
        [Define to 1 if ]hdr[ is available])]
    [AC_CHECK_HEADERS([hdr])]
)

Causes config.h.in (assuming AC_CONFIG_HEADERS([config.h])) to have a template:

/* Define to 1 if you have the <hdr> header file.*/
#undef HAVE_HDR

Is there any way to avoid that bogus template? Note that the m4_foreach_w is being invoked inside a macro and the actual text is m4_foreach_w([hdr],[$1], and I’m wondering if I have an m4 quoting issue, but I suspect the problem is more fundamental. Which is to say, I always assume I’ve misquoted the m4–but that does not seem to be the problem here. Rather, autoheader is scanning the text without honoring the m4_foreach_w. I don’t think the template causes any problems, but it looks really weird in the final config.h.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:07:27+00:00Added an answer on June 11, 2026 at 10:07 pm

    Note that autoheader does not “scan” configure.ac. Rather, it runs configure.ac through m4 in trace mode, in order to catch low-level calls to AC_DEFINE_TRACE_LITERAL (which is called indirectly by AC_DEFINE) and to AH_OUTPUT (called byAC_CHECK_HEADERS). So because everything goes through m4, autoheader does not ignore m4_foreach. However it sees the arguments the way they are actually received by the macros.

    You can see the problem in your code by tracing the calls to AC_DEFINE and AC_CHECK_HEADERS in your configure.ac:

    % cat configure.ac
    AC_INIT(somelib.so, 1.0, someone@somewhere.com)
    m4_foreach_w([hdr],[[foo.h] [bar.h]], [
         AC_DEFINE([HAVE_]m4_translit(m4_toupper(hdr),[/.],[__]),[1],
            [Define to 1 if ]hdr[ is available])
         AC_CHECK_HEADERS([hdr])
    ])
    AC_CONFIG_HEADERS([config.h])
    AC_OUTPUT
    % autoconf -t AC_DEFINE -t AC_CHECK_HEADERS
    configure.ac:3:AC_DEFINE:HAVE_FOO_H:1:Define to 1 if foo.h is available
    configure.ac:3:AC_CHECK_HEADERS:hdr
    configure.ac:3:AC_DEFINE:STDC_HEADERS:1:Define to 1 if you have the ANSI C header files.
    configure.ac:3:AC_CHECK_HEADERS:sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h inttypes.h stdint.h unistd.h:::$ac_includes_default
    configure.ac:3:AC_DEFINE:HAVE_BAR_H:1:Define to 1 if bar.h is available
    configure.ac:3:AC_CHECK_HEADERS:hdr
    

    So we see that AC_CHECK_HEADERS is called twice with hdr as argument. While in the call to AC_DEFINE, hdr has been correctly expanded. That’s because hdr is quoted one more time in your call to AC_CHECK_HEADERS, preventing its expansion.

    I’d fix it this way:

    m4_foreach_w([hdr],[[foo.h] [bar.h]], [
         AC_DEFINE([HAVE_]m4_translit(m4_toupper(hdr),[/.],[__]),[1],
            [Define to 1 if ]hdr[ is available])
         AC_CHECK_HEADERS(hdr)
    ])
    

    (But that is still assuming that the names foo.h and bar.h will never trigger any macro.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What do I need to do to get APC to work correctly, it seems
Does anyone know of a C# spell check library that would underline misspelled works
I'm writing a C application which creates a Windows service. I'd like to check
Given userplays = { Alice : { AC/DC : 2, The Raconteurs : 3,
How do I customize the ac_results class generated by the autocomplete plugin?
On this page http://equals.lsri.nottingham.ac.uk/puzzle/create , if you type something into an input and then
ab.txt 30 abcd 45 sadsad ac.txt 50 ab 430 sadsad how can i join
$query1 = SELECT id, ac, aa FROM tbl_ac WHERE ac = ? AND aa
I'm trying to determine if a laptop is connected to AC power. The OS
My Code: foreach (PicasaEntry entryAlbuns in feedAlbuns.Entries) { AlbumAccessor ac = new AlbumAccessor(entryAlbuns); PhotoQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.