public inbox for bzip2-devel@sourceware.org
 help / color / mirror / Atom feed
* Unable to build under Windows
@ 2022-02-19 21:45 Dmitry Tsarevich
  2022-04-19 22:36 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Tsarevich @ 2022-02-19 21:45 UTC (permalink / raw)
  To: bzip2-devel

Hello!

I'm trying to build bzip2 under Windows / MSVC

Unfortunately, STDERR_FILENO is *nix specific and is not defined under MSVC.

What I can suggest is to patch bzip2.c to define STDERR_FILENO under MSVC:

diff --git a/bzip2.c b/bzip2.c
index d1f2fa8..d4550a9 100644
--- a/bzip2.c
+++ b/bzip2.c
@@ -150,6 +150,8 @@
          ERROR_IF_MINUS_ONE ( retVal );               \
       } while ( 0 )

+#define STDERR_FILENO _fileno(stderr)
+
 #endif /* BZ_LCCWIN32 */

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

* Re: Unable to build under Windows
  2022-02-19 21:45 Unable to build under Windows Dmitry Tsarevich
@ 2022-04-19 22:36 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2022-04-19 22:36 UTC (permalink / raw)
  To: Dmitry Tsarevich; +Cc: bzip2-devel

[-- Attachment #1: Type: text/plain, Size: 777 bytes --]

Hi Dmitry,

On Sun, Feb 20, 2022 at 12:45:06AM +0300, Dmitry Tsarevich via Bzip2-devel wrote:
> I'm trying to build bzip2 under Windows / MSVC
> 
> Unfortunately, STDERR_FILENO is *nix specific and is not defined under MSVC.
> 
> What I can suggest is to patch bzip2.c to define STDERR_FILENO under MSVC:
> 
> diff --git a/bzip2.c b/bzip2.c
> index d1f2fa8..d4550a9 100644
> --- a/bzip2.c
> +++ b/bzip2.c
> @@ -150,6 +150,8 @@
>           ERROR_IF_MINUS_ONE ( retVal );               \
>        } while ( 0 )
> 
> +#define STDERR_FILENO _fileno(stderr)
> +
>  #endif /* BZ_LCCWIN32 */

I cannot test myself under Windows / MSVC, but that seems a reasonable
suggestion. Especially since fileno is already used inside this
BZ_LCCWIN32 block. I pushed the attached.

Thanks,

Mark

[-- Attachment #2: 0001-Define-STDERR_FILENO-for-BZ_LCCWIN32.patch --]
[-- Type: text/x-diff, Size: 683 bytes --]

From 28da6196a27de951d6143d4f2765d1f2976f0d39 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Wed, 20 Apr 2022 00:31:01 +0200
Subject: [PATCH] Define STDERR_FILENO for BZ_LCCWIN32

STDERR_FILENO is *nix specific and is not defined under MSVC.
So define it using _fileno(stderr).

Suggested-by: Dmitry Tsarevich <dimhotepus@gmail.com>
---
 bzip2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/bzip2.c b/bzip2.c
index d1f2fa8..1538faf 100644
--- a/bzip2.c
+++ b/bzip2.c
@@ -150,6 +150,8 @@
          ERROR_IF_MINUS_ONE ( retVal );               \
       } while ( 0 )
 
+#   define STDERR_FILENO _fileno(stderr)
+
 #endif /* BZ_LCCWIN32 */
 
 
-- 
2.30.2


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

end of thread, other threads:[~2022-04-19 22:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-19 21:45 Unable to build under Windows Dmitry Tsarevich
2022-04-19 22:36 ` Mark Wielaard

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).