1 ?RCS: $Id: d_static_inline.U,v $
3 ?RCS: Copyright (c) 2010 Andrew Dougherty
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
11 ?RCS: Original Author: Andy Dougherty <doughera@lafayette.edu>
13 ?MAKE:d_static_inline perl_static_inline: Compile Setvar cat echo run rm_try
14 ?MAKE: -pick add $@ %<
16 ?S: This variable conditionally defines the HAS_STATIC_INLINE symbol,
17 ?S: which indicates that the C compiler supports C99-style static
18 ?S: inline. That is, the function can't be called from another
21 ?S:perl_static_inline:
22 ?S: This variable defines the PERL_STATIC_INLINE symbol to
23 ?S: the best-guess incantation to use for static inline functions.
24 ?S: Possibilities include
25 ?S: static inline (c99)
26 ?S: static __inline__ (gcc -ansi)
27 ?S: static __inline (MSVC)
28 ?S: static (c89 compilers)
30 ?C:HAS_STATIC_INLINE :
31 ?C: This symbol, if defined, indicates that the C compiler supports
32 ?C: supports C99-style static inline. That is, the function can't
33 ?C: be called from another translation unit.
35 ?C:PERL_STATIC_INLINE:
36 ?C: This symbol gives the best-guess incantation to use for static
37 ?C: inline functions. If HAS_STATIC_INLINE is defined, this will
38 ?C: give C99-style inline. If HAS_STATIC_INLINE is not defined,
39 ?C: this will give a plain 'static'. It will always be defined
40 ?C: to something that gives static linkage.
41 ?C: Possibilities include
42 ?C: static inline (c99)
43 ?C: static __inline__ (gcc -ansi)
44 ?C: static __inline (MSVC)
45 ?C: static (c89 compilers)
47 ?H:#$d_static_inline HAS_STATIC_INLINE /**/
48 ?H:#define PERL_STATIC_INLINE $perl_static_inline /**/
50 ?LINT:set d_static_inline
52 : see what flavor, if any, of static inline is supported
54 ?X: Build two programs. The first uses static inline in file a.c and
55 ?X: should work. The second also includes b.c which tries to link against
56 ?X: the static function in a.c. This should fail.
60 extern int f_via_a(int x);
61 extern int f_via_b(int x);
62 int main(int argc, char **argv)
79 static inline int f(int x) {
100 if eval $compile && $run ./try; then
101 # Now make sure there is no external linkage of static
103 set try -DUSE_B a.c b.c
104 if eval $compile && $run ./try; then
105 $echo "Your compiler supports static inline, " >&4
106 $echo "but it also creates an external definition," >&4
107 $echo "so I won't use it." >&4
110 $echo "Your compiler supports static inline." >&4
114 $echo "Your compiler does NOT support static inline." >&4