File: static-inline.texi

package info (click to toggle)
gnulib 20250303-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 188,836 kB
  • sloc: ansic: 378,598; sh: 30,630; python: 8,358; cpp: 2,811; yacc: 1,846; perl: 920; makefile: 577; lisp: 328; sed: 11; java: 5
file content (34 lines) | stat: -rw-r--r-- 1,395 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
@c Documentation of gnulib module 'inline'.

@c Copyright (C) 2019--2025 Free Software Foundation, Inc.

@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.3 or
@c any later version published by the Free Software Foundation; with no
@c Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.  A
@c copy of the license is at <https://www.gnu.org/licenses/fdl-1.3.en.html>.

@node static inline
@section Static inline functions

@cindex static inline
@cindex inline

In order to mark functions as @code{static inline} in @code{.c} files,
the only prerequisite you need is an @code{AC_REQUIRE([AC_C_INLINE])}.
No Gnulib module is needed.

@mindex inline
When marking functions as @code{static inline} in @code{.h} files,
on the other hand,
it is useful to avoid the following problem:
When gcc or clang is not optimizing, it generates the same object code
for every @code{static inline} function
that is actually used in the current compilation unit,
thus bloating the size of the resulting binary.
(Code of @code{static inline} functions
that are unused in the current compilation unit gets dropped;
that is not an issue.)
To avoid this problem, use the Gnulib module @samp{inline}
and make the @code{static inline} function definition conditional
on the value of the C macro @code{HAVE_INLINE}.