Bug 23568 - gdb/ser-mingw.c: error: 'ERROR_IO_PENDING' was not declared in this scope (MinGW/MSYS)
Summary: gdb/ser-mingw.c: error: 'ERROR_IO_PENDING' was not declared in this scope (Mi...
Status: WAITING
Alias: None
Product: gdb
Classification: Unclassified
Component: build (show other bugs)
Version: 7.12.1
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 23583 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-08-24 08:28 UTC by SiZiOUS
Modified: 2022-12-02 16:26 UTC (History)
2 users (show)

See Also:
Host: mingw32
Target: sh-elf
Build:
Last reconfirmed: 2022-12-02 00:00:00


Attachments
Fix to allow MinGW/MSYS compilation of gdb-7.12.1 (8.53 KB, text/plain)
2018-08-24 08:36 UTC, SiZiOUS
Details
Patch to allow MinGW/MSYS compilation of gdb-7.12.1 (207 bytes, patch)
2018-08-24 08:41 UTC, SiZiOUS
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description SiZiOUS 2018-08-24 08:28:10 UTC
When compiling under the original MSYS/MinGW environment (downloaded from www.mingw.org, i.e. NOT MinGW-w64/MSYS2, as I need Windows XP support), a compilation error is thrown from the "gdb/ser-mingw.c" file:

../../gdb-7.12.1/gdb/ser-mingw.c: In function 'int ser_windows_read_prim(serial*, size_t)':
../../gdb-7.12.1/gdb/ser-mingw.c:346:30: error: 'ERROR_IO_PENDING' was not declared in this scope
       if (GetLastError () != ERROR_IO_PENDING
                              ^~~~~~~~~~~~~~~~
../../gdb-7.12.1/gdb/ser-mingw.c: In function 'int ser_windows_write_prim(serial*, const void*, size_t)':
../../gdb-7.12.1/gdb/ser-mingw.c:368:30: error: 'ERROR_IO_PENDING' was not declared in this scope
       if (GetLastError () != ERROR_IO_PENDING
                              ^~~~~~~~~~~~~~~~
make[3]: *** [ser-mingw.o] Error 1

Note: The host is "mingw32" and the target is "sh-elf".

PROPOSED CORRECTION:
I solved this bug by adding the following code snippet directly in the "gdb/ser-mingw.c" file:

#ifndef ERROR_IO_PENDING
// In MinGW (original project, for MinGW-w64 I don't know), this code is defined in that header file.
#include <winerror.h>
#endif

After that modification, the compilation of gdb-7.12.1 with host "mingw32" and targetting "sh-elf" is successful.
Comment 1 SiZiOUS 2018-08-24 08:36:24 UTC
Created attachment 11208 [details]
Fix to allow MinGW/MSYS compilation of gdb-7.12.1
Comment 2 SiZiOUS 2018-08-24 08:39:42 UTC
Comment on attachment 11208 [details]
Fix to allow MinGW/MSYS compilation of gdb-7.12.1

--- ser-mingw.c	2017-01-21 13:46:47 +0000
+++ ser-mingw.c.patch	2018-08-24 08:30:27 +0000
@@ -31,6 +31,10 @@
 
 #include "command.h"
 
+#ifndef ERROR_IO_PENDING
+#include <winerror.h>
+#endif
+
 void _initialize_ser_windows (void);
 
 struct ser_windows_state
Comment 3 SiZiOUS 2018-08-24 08:40:54 UTC
Comment on attachment 11208 [details]
Fix to allow MinGW/MSYS compilation of gdb-7.12.1

--- ser-mingw.c	2017-01-21 13:46:47 +0000
+++ ser-mingw.c.patch	2018-08-24 08:30:27 +0000
@@ -31,6 +31,10 @@
 
 #include "command.h"
 
+#ifndef ERROR_IO_PENDING
+#include <winerror.h>
+#endif
+
 void _initialize_ser_windows (void);
 
 struct ser_windows_state
Comment 4 SiZiOUS 2018-08-24 08:41:59 UTC
Created attachment 11209 [details]
Patch to allow MinGW/MSYS compilation of gdb-7.12.1
Comment 5 Tom Tromey 2018-08-24 13:59:40 UTC
Thanks for the patch.  The gdb project doesn't review patches in
bugzilla; instead they must be sent to the gdb-patches list.
See the contribution checklist for details:
https://sourceware.org/gdb/wiki/ContributionChecklist
Comment 6 SiZiOUS 2018-08-28 10:12:22 UTC
Thanks for your feedback. I confirm that gdb-7.12.1 is compiling fine under MSYS/MinGW with this little patch applied. I'll submit the patch to the list as requested.
Comment 7 SiZiOUS 2018-08-28 12:02:23 UTC
I just submitted the patch now. I hope I respected all the guidelines of the list.
Comment 8 Tom Tromey 2018-09-26 11:49:44 UTC
What's the status of this?
Comment 9 SiZiOUS 2018-12-02 13:07:14 UTC
Sorry, long time no see.
The bug will not be fixed as 7.12.1 is an old release.
But the thing is, this bug is still here in 8.2.
Comment 10 Hannes Domani 2020-04-08 23:26:56 UTC
(In reply to SiZiOUS from comment #3)
> Comment on attachment 11208 [details]
> Fix to allow MinGW/MSYS compilation of gdb-7.12.1
> 
> --- ser-mingw.c	2017-01-21 13:46:47 +0000
> +++ ser-mingw.c.patch	2018-08-24 08:30:27 +0000
> @@ -31,6 +31,10 @@
>  
>  #include "command.h"
>  
> +#ifndef ERROR_IO_PENDING
> +#include <winerror.h>
> +#endif
> +
>  void _initialize_ser_windows (void);
>  
>  struct ser_windows_state

That shouldn't be necessary, winerror.h should be included by windows.h (indirectly, via winbase.h).
Comment 11 Tom Tromey 2022-02-27 23:29:07 UTC
*** Bug 23583 has been marked as a duplicate of this bug. ***
Comment 12 Tom Tromey 2022-02-27 23:35:34 UTC
Did anybody ever get to the bottom of this?
One approach would be to attach the preprocessed source here.
The question is why this isn't defined by the windows.h includes.
Comment 13 Tom Tromey 2022-12-02 16:26:17 UTC
Waiting for response.