GNU bug report logs - #14830
[PATCH] * configure.ac (HAVE_W32): Avoid nested functions

Previous Next

Package: emacs;

Reported by: Peter Rosin <peda <at> lysator.liu.se>

Date: Mon, 8 Jul 2013 22:51:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Peter Rosin <peda <at> lysator.liu.se>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 14830 <at> debbugs.gnu.org
Subject: bug#14830: [PATCH] * configure.ac (HAVE_W32): Avoid nested functions
Date: Tue, 09 Jul 2013 08:27:33 +0200
On 2013-07-09 04:41, Eli Zaretskii wrote:
>> Date: Tue, 09 Jul 2013 00:49:43 +0200
>> From: Peter Rosin <peda <at> lysator.liu.se>
>>
>> diff --git a/ChangeLog b/ChangeLog
>> index 220cffb..03011cf 100644
>> --- a/ChangeLog
>> +++ b/ChangeLog
>> @@ -1,3 +1,8 @@
>> +2013-07-09  Peter Rosin <peda <at> lysator.liu.se>  (tiny change>
>> +
>> +	* configure.ac (HAVE_W32): Avoid nested functions (the second
>> +	argument of AC_LANG_PROGRAM is expanded inside a function).
>> +
>>  2013-07-08  Magnus Henoch <magnus.henoch <at> gmail.com> (tiny change)
>>
>>  	* configure.ac (HAVE_IMAGEMAGICK): Check on NS also (Bug#14798).
>> diff --git a/configure.ac b/configure.ac
>> index 3830ee3..1188f1b 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -1632,10 +1632,10 @@ fi
>>
>>  if test "${opsys}" = "mingw32"; then
>>    AC_MSG_CHECKING([whether Windows API headers are recent enough])
>> -  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
>> +  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
>>       #include <windows.h>
>> -     #include <usp10.h>]],
>> -   [[void test(PIMAGE_NT_HEADERS pHeader)
>> +     #include <usp10.h>
>> +     void test(PIMAGE_NT_HEADERS pHeader)
>>       {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);}]])],
>>     [emacs_cv_w32api=yes
>>      HAVE_W32=yes],
> 
> Sorry, I don't follow: what is the problem with the current code?
> 

AC_LANG_PROGRAM([[
     #include <windows.h>
     #include <usp10.h>]],
   [[void test(PIMAGE_NT_HEADERS pHeader)
     {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);}]])

is expanded into the following program (enhanced whitespace):

#include <windows.h>
#include <usp10.h>

int
main ()
{
  void test(PIMAGE_NT_HEADERS pHeader)
  {
    PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);
  }
  ;
  return 0;
}

My fixed version with AC_LANG_SOURCE will not emit the main() function
and thus avoids nested functions and instead generates this source (again
with enhanced whitespace):

#include <windows.h>
#include <usp10.h>

void
test(PIMAGE_NT_HEADERS pHeader)
{
  PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);
}

The background is that when trying to configure with an unsupported
compiler, MSVC in this case, it errors out with "the Windows API
headers are too old to support this build", which is a bogus error
message.

Agreed, it doesn't really change anything for supported configurations,
but being able to nest functions has nothing to do with the test at
hand.

Cheers,
Peter





This bug report was last modified 11 years and 321 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.