Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

.\"	$NetBSD: __FPTRCAST.3,v 1.2 2019/11/11 11:06:27 wiz Exp $ $
.\"
.\" Copyright (c) 2019 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Christos Zoulas
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 17, 2013
.Dt __FPTRCAST 3
.Os
.Sh NAME
.Nm __FPTRCAST
.Nd function pointer cast
.Sh SYNOPSIS
.In sys/cdefs.h
.Ft ftype
.Fn __FPTRCAST ftype fname
.Sh DESCRIPTION
The
.Fn __FPTRCAST
macro can be used to silence warnings produced by certain compilers when
converting from one function pointer type to another.
The
.Fa ftype
argument is the function pointer type to which to cast the function
pointer in
.Fa fname .
.Pp
This cast should be used sparingly and it is typically used in the following
situations:
.Bl -bullet -offset indent -compact
.It
We know that the function prototypes don't match at all, but we don't care
because we point it to a function that does not take arguments and returns
an error.
.It
We only care about the first few arguments and we don't care about the rest.
.It
We don't care about the return value, we ignore it anyway.
.El
.Sh IMPLEMENTATION NOTES
This macro is implemented by using an intermediate
.Em void *
cast.
.Sh SEE ALSO
.Xr cc 1 ,
.Xr cdefs 3
.Sh CAVEATS
Use of this macro can hide valid errors, and its usage is not recommended
unless there is a well-thought reason for a cast.
As a general guideline, don't use this macro inside other macros because
it will hide cases where the user of the original macro accidentally used
an incorrect function pointer.
.Pp
Use of this macro is non-portable; this is part of the implementation
namespace and should only be used in
.Nx
code.