xref: /netbsd-src/share/man/man3/__FPTRCAST.3 (revision 5952ea0ef13460e7b76a8e483cc35cd8a8cef379)
1.\"	$NetBSD: __FPTRCAST.3,v 1.2 2019/11/11 11:06:27 wiz Exp $ $
2.\"
3.\" Copyright (c) 2019 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Christos Zoulas
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd October 17, 2013
31.Dt __FPTRCAST 3
32.Os
33.Sh NAME
34.Nm __FPTRCAST
35.Nd function pointer cast
36.Sh SYNOPSIS
37.In sys/cdefs.h
38.Ft ftype
39.Fn __FPTRCAST ftype fname
40.Sh DESCRIPTION
41The
42.Fn __FPTRCAST
43macro can be used to silence warnings produced by certain compilers when
44converting from one function pointer type to another.
45The
46.Fa ftype
47argument is the function pointer type to which to cast the function
48pointer in
49.Fa fname .
50.Pp
51This cast should be used sparingly and it is typically used in the following
52situations:
53.Bl -bullet -offset indent -compact
54.It
55We know that the function prototypes don't match at all, but we don't care
56because we point it to a function that does not take arguments and returns
57an error.
58.It
59We only care about the first few arguments and we don't care about the rest.
60.It
61We don't care about the return value, we ignore it anyway.
62.El
63.Sh IMPLEMENTATION NOTES
64This macro is implemented by using an intermediate
65.Em void *
66cast.
67.Sh SEE ALSO
68.Xr cc 1 ,
69.Xr cdefs 3
70.Sh CAVEATS
71Use of this macro can hide valid errors, and its usage is not recommended
72unless there is a well-thought reason for a cast.
73As a general guideline, don't use this macro inside other macros because
74it will hide cases where the user of the original macro accidentally used
75an incorrect function pointer.
76.Pp
77Use of this macro is non-portable; this is part of the implementation
78namespace and should only be used in
79.Nx
80code.
81