Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 884
    • Issues 884
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 44
    • Merge requests 44
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOME
  • GLib
  • Merge requests
  • !1226

gclosure: avoid -Wincompatible-pointer-types compiler warning for G_CALLBACK() cast macro

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Thomas Haller requested to merge thaller/glib:th/g-callback-cast-warning into master Nov 14, 2019
  • Overview 2
  • Commits 1
  • Pipelines 1
  • Changes 1

The -Wincompatible-pointer-types compiler warning [1] is very useful to catch wrong casts for function pointers. It flags in uses where the function signature is incompatible with the desired type.

However see for example g_source_set_callback() function which expects a GCallback function argument. Then we have sources like g_unix_fd_add(), which expect a callback with a GUnixFDSourceFunc signature.

The cast macro was not usable for this purpose, if it doesn't silence the cast warning.

Compare also G_SOURCE_FUNC() macro which does a similar thing [2]. The difference is that G_SOURCE_FUNC() was added exactly for this purpose from the start. Here, the commit changes a pre-existing G_CALLBACK() macro and silences warnings. I still think this change is desirable.

[1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wcast-function-type

[2] 039fa689

Edited Nov 14, 2019 by Thomas Haller
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: th/g-callback-cast-warning