Skip to content

compress.c: fix -std=c23 build failure (signal handler protos)#40

Open
trofi wants to merge 1 commit into
vapier:mainfrom
trofi:gcc-15-c23
Open

compress.c: fix -std=c23 build failure (signal handler protos)#40
trofi wants to merge 1 commit into
vapier:mainfrom
trofi:gcc-15-c23

Conversation

@trofi

@trofi trofi commented Nov 16, 2024

Copy link
Copy Markdown

gcc-15 switched to -std=c23 by default:

https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212

As a result ncompress fails the build as:

compress.c: In function 'main':
compress.c:382:40: error:
  passing argument 2 of 'signal' from incompatible pointer type [-Wincompatible-pointer-types]
  382 |                         signal(SIGINT, (SIG_TYPE)abort_compress);
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~
      |                                        |
      |                                        void (*)(void)
In file included from compress.c:30:
...-glibc-2.40-36-dev/include/signal.h:88:57: note:
  expected '__sighandler_t' {aka 'void (*)(int)'} but argument is of type 'void (*)(void)'
   88 | extern __sighandler_t signal (int __sig, __sighandler_t __handler)
      |                                          ~~~~~~~~~~~~~~~^~~~~~~~~

The change removes type casts around function prototypes and define signal handler as void(*)(int).

gcc-15 switched to -std=c23 by default:

    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212

As a result `ncompress` fails the build as:

    compress.c: In function 'main':
    compress.c:382:40: error:
      passing argument 2 of 'signal' from incompatible pointer type [-Wincompatible-pointer-types]
      382 |                         signal(SIGINT, (SIG_TYPE)abort_compress);
          |                                        ^~~~~~~~~~~~~~~~~~~~~~~~
          |                                        |
          |                                        void (*)(void)
    In file included from compress.c:30:
    ...-glibc-2.40-36-dev/include/signal.h:88:57: note:
      expected '__sighandler_t' {aka 'void (*)(int)'} but argument is of type 'void (*)(void)'
       88 | extern __sighandler_t signal (int __sig, __sighandler_t __handler)
          |                                          ~~~~~~~~~~~~~~~^~~~~~~~~

The change removes type casts around function prototypes and define
signal handler as `void(*)(int)`.
@kloczek

kloczek commented May 5, 2025

Copy link
Copy Markdown

IMO it would be good to merge this PR and release new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants