unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14830: [PATCH] * configure.ac (HAVE_W32): Avoid nested functions
@ 2013-07-08 22:49 Peter Rosin
  2013-07-09  2:41 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Rosin @ 2013-07-08 22:49 UTC (permalink / raw)
  To: 14830

diff --git a/ChangeLog b/ChangeLog
index 220cffb..03011cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-07-09  Peter Rosin <peda@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@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],
--
1.7.9





^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#14830: [PATCH] * configure.ac (HAVE_W32): Avoid nested functions
  2013-07-08 22:49 bug#14830: [PATCH] * configure.ac (HAVE_W32): Avoid nested functions Peter Rosin
@ 2013-07-09  2:41 ` Eli Zaretskii
  2013-07-09  6:27   ` Peter Rosin
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2013-07-09  2:41 UTC (permalink / raw)
  To: Peter Rosin; +Cc: 14830

> Date: Tue, 09 Jul 2013 00:49:43 +0200
> From: Peter Rosin <peda@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@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@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?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#14830: [PATCH] * configure.ac (HAVE_W32): Avoid nested functions
  2013-07-09  2:41 ` Eli Zaretskii
@ 2013-07-09  6:27   ` Peter Rosin
  2013-07-09  6:53     ` Peter Rosin
  2013-07-09  6:56     ` Andreas Schwab
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Rosin @ 2013-07-09  6:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 14830

On 2013-07-09 04:41, Eli Zaretskii wrote:
>> Date: Tue, 09 Jul 2013 00:49:43 +0200
>> From: Peter Rosin <peda@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@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@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






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#14830: [PATCH] * configure.ac (HAVE_W32): Avoid nested functions
  2013-07-09  6:27   ` Peter Rosin
@ 2013-07-09  6:53     ` Peter Rosin
  2013-07-09  7:17       ` Andreas Schwab
  2013-07-09  6:56     ` Andreas Schwab
  1 sibling, 1 reply; 8+ messages in thread
From: Peter Rosin @ 2013-07-09  6:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 14830

On 2013-07-09 08:27, Peter Rosin wrote:
> On 2013-07-09 04:41, Eli Zaretskii wrote:
>>> Date: Tue, 09 Jul 2013 00:49:43 +0200
>>> From: Peter Rosin <peda@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@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@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.

Hmm, the below variant is perhaps clearer?

It expands into:

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

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

Cheers,
Peter


diff --git a/ChangeLog b/ChangeLog
index 220cffb..3ba3093 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-07-09  Peter Rosin <peda@lysator.liu.se>  (tiny change>
+
+       * configure.ac (HAVE_W32): Avoid nested functions (the second
+       argument of AC_LANG_PROGRAM is already expanded inside a function).
+
 2013-07-08  Magnus Henoch <magnus.henoch@gmail.com> (tiny change)

        * configure.ac (HAVE_IMAGEMAGICK): Check on NS also (Bug#14798).
diff --git a/configure.ac b/configure.ac
index 3830ee3..ddfef68 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1635,8 +1635,7 @@ if test "${opsys}" = "mingw32"; then
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
      #include <windows.h>
      #include <usp10.h>]],
-   [[void test(PIMAGE_NT_HEADERS pHeader)
-     {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);}]])],
+   [[PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)]])],
    [emacs_cv_w32api=yes
     HAVE_W32=yes],
    emacs_cv_w32api=no)
--
1.7.9







^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#14830: [PATCH] * configure.ac (HAVE_W32): Avoid nested functions
  2013-07-09  6:27   ` Peter Rosin
  2013-07-09  6:53     ` Peter Rosin
@ 2013-07-09  6:56     ` Andreas Schwab
  1 sibling, 0 replies; 8+ messages in thread
From: Andreas Schwab @ 2013-07-09  6:56 UTC (permalink / raw)
  To: Peter Rosin; +Cc: 14830

Peter Rosin <peda@lysator.liu.se> writes:

> 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);
> }

You should instead remove the function.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#14830: [PATCH] * configure.ac (HAVE_W32): Avoid nested functions
  2013-07-09  6:53     ` Peter Rosin
@ 2013-07-09  7:17       ` Andreas Schwab
  2013-07-09  8:07         ` Peter Rosin
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2013-07-09  7:17 UTC (permalink / raw)
  To: Peter Rosin; +Cc: 14830

Peter Rosin <peda@lysator.liu.se> writes:

> #include <windows.h>
> #include <usp10.h>
>
> int
> main ()
> {
>   PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);

You need to declare pHeader somewhere.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#14830: [PATCH] * configure.ac (HAVE_W32): Avoid nested functions
  2013-07-09  7:17       ` Andreas Schwab
@ 2013-07-09  8:07         ` Peter Rosin
  2013-07-09 18:07           ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Rosin @ 2013-07-09  8:07 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 14830

On 2013-07-09 09:17, Andreas Schwab wrote:
> Peter Rosin <peda@lysator.liu.se> writes:
> 
>> #include <windows.h>
>> #include <usp10.h>
>>
>> int
>> main ()
>> {
>>   PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);
> 
> You need to declare pHeader somewhere.

Big sigh. Thanks for catching...

Cheers,
Peter

diff --git a/ChangeLog b/ChangeLog
index 220cffb..3ba3093 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-07-09  Peter Rosin <peda@lysator.liu.se>  (tiny change>
+
+       * configure.ac (HAVE_W32): Avoid nested functions (the second
+       argument of AC_LANG_PROGRAM is already expanded inside a function).
+
 2013-07-08  Magnus Henoch <magnus.henoch@gmail.com> (tiny change)

        * configure.ac (HAVE_IMAGEMAGICK): Check on NS also (Bug#14798).
diff --git a/configure.ac b/configure.ac
index 3830ee3..bb140a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1635,8 +1635,8 @@ if test "${opsys}" = "mingw32"; then
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
      #include <windows.h>
      #include <usp10.h>]],
-   [[void test(PIMAGE_NT_HEADERS pHeader)
-     {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);}]])],
+   [[PIMAGE_NT_HEADERS pHeader;
+     PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)]])],
    [emacs_cv_w32api=yes
     HAVE_W32=yes],
    emacs_cv_w32api=no)
--
1.7.9







^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#14830: [PATCH] * configure.ac (HAVE_W32): Avoid nested functions
  2013-07-09  8:07         ` Peter Rosin
@ 2013-07-09 18:07           ` Eli Zaretskii
  0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2013-07-09 18:07 UTC (permalink / raw)
  To: Peter Rosin; +Cc: schwab, 14830-done

> Date: Tue, 09 Jul 2013 10:07:28 +0200
> From: Peter Rosin <peda@lysator.liu.se>
> CC: Eli Zaretskii <eliz@gnu.org>, 14830@debbugs.gnu.org
> 
> On 2013-07-09 09:17, Andreas Schwab wrote:
> > Peter Rosin <peda@lysator.liu.se> writes:
> > 
> >> #include <windows.h>
> >> #include <usp10.h>
> >>
> >> int
> >> main ()
> >> {
> >>   PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);
> > 
> > You need to declare pHeader somewhere.
> 
> Big sigh. Thanks for catching...

Thanks, committed as trunk revision 113349.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-07-09 18:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-08 22:49 bug#14830: [PATCH] * configure.ac (HAVE_W32): Avoid nested functions Peter Rosin
2013-07-09  2:41 ` Eli Zaretskii
2013-07-09  6:27   ` Peter Rosin
2013-07-09  6:53     ` Peter Rosin
2013-07-09  7:17       ` Andreas Schwab
2013-07-09  8:07         ` Peter Rosin
2013-07-09 18:07           ` Eli Zaretskii
2013-07-09  6:56     ` Andreas Schwab

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).