1Filter::cpp(3)        User Contributed Perl Documentation       Filter::cpp(3)
2
3
4

NAME

6       Filter::cpp - cpp source filter
7

SYNOPSIS

9           use Filter::cpp ;
10

DESCRIPTION

12       This source filter pipes the current source file through the C pre-
13       processor (cpp) if it is available.
14
15       As with all source filters its scope is limited to the current source
16       file only. Every file you want to be processed by the filter must have
17       a
18
19           use Filter::cpp ;
20
21       near the top.
22
23       Here is an example script which uses the filter:
24
25           use Filter::cpp ;
26
27           #define FRED 1
28           $a = 2 + FRED ;
29           print "a = $a\n" ;
30           #ifdef FRED
31           print "Hello FRED\n" ;
32           #else
33           print "Where is FRED\n" ;
34           #endif
35
36       And here is what it will output:
37
38           a = 3
39           Hello FRED
40
41       This example below, provided by Michael G Schwern, shows a clever way
42       to get Perl to use a C pre-processor macro when the Filter::cpp module
43       is available, or to use a Perl sub when it is not.
44
45           # use Filter::cpp if we can.
46           BEGIN { eval 'use Filter::cpp' }
47
48           sub PRINT {
49               my($string) = shift;
50
51           #define PRINT($string) \
52               (print $string."\n")
53           }
54
55           PRINT("Mu");
56
57       Look at Michael's Tie::VecArray module for a practical use.
58

AUTHOR

60       Paul Marquess
61

DATE

63       11th December 1995.
64
65
66
67perl v5.28.1                      2018-08-04                    Filter::cpp(3)
Impressum