Skip to content

Commit

Permalink
libhb/gtk: do not modify stderr struct directly on mingw (HandBrake#5945
Browse files Browse the repository at this point in the history
)

Breaks mingw build when using UCRT:

../libhb/hb.c: In function 'redirect_thread_func':
../libhb/hb.c:2314:11: error: 'FILE' {aka 'struct _iobuf'} has no member named '_file'
 2314 |     stderr->_file = pfd[1];
      |           ^~

See:

mingw-w64/mingw-w64@fe226dd
  • Loading branch information
marcosfrm authored Jun 16, 2024
1 parent 071ae02 commit 6209e23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gtk/src/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,8 +995,8 @@ ghb_application_handle_local_options (GApplication *app, GVariantDict *options)
{
// Non-console windows apps do not have a stderr->_file
// assigned properly
stderr->_file = STDERR_FILENO;
stdout->_file = STDOUT_FILENO;
(void) freopen("NUL", "w", stderr);
(void) freopen("NUL", "w", stdout);
}
#else
redirect_io = FALSE;
Expand Down
10 changes: 7 additions & 3 deletions libhb/hb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2310,11 +2310,15 @@ static void redirect_thread_func(void * _data)
if (pipe(pfd))
return;
#if defined( SYS_MINGW )
// dup2 doesn't work on windows for some stupid reason
stderr->_file = pfd[1];
// Non-console windows apps do not have a stderr->_file
// assigned properly
(void) freopen("NUL", "w", stderr);
_dup2(pfd[1], _fileno(stderr));
#else
dup2(pfd[1], /*stderr*/ 2);
dup2(pfd[1], STDERR_FILENO);
#endif
setvbuf(stderr, NULL, _IONBF, 0);

FILE * log_f = fdopen(pfd[0], "rb");

char line_buffer[500];
Expand Down

0 comments on commit 6209e23

Please sign in to comment.