1ExtUtils::CppGuess(3) User Contributed Perl DocumentationExtUtils::CppGuess(3)
2
3
4
6 ExtUtils::CppGuess - guess C++ compiler and flags
7
9 With Extutils::MakeMaker:
10
11 use ExtUtils::CppGuess;
12
13 my $guess = ExtUtils::CppGuess->new;
14
15 WriteMakefile
16 ( # MakeMaker args,
17 $guess->makemaker_options,
18 );
19
20 With Module::Build:
21
22 my $guess = ExtUtils::CppGuess->new;
23
24 my $build = Module::Build->new
25 ( # Module::Build arguments
26 $guess->module_build_options,
27 );
28 $build->create_build_script;
29
31 "ExtUtils::CppGuess" attempts to guess the system's C++ compiler that
32 is compatible with the C compiler that your perl was built with.
33
34 It can generate the necessary options to the Module::Build constructor
35 or to ExtUtils::MakeMaker's "WriteMakefile" function.
36
38 new
39 Creates a new "ExtUtils::CppGuess" object. Takes the path to the C
40 compiler as the "cc" argument, but falls back to the value of
41 $Config{cc}, which should be what you want anyway.
42
43 You can specify "extra_compiler_flags" and "extra_linker_flags" (as
44 strings) which will be merged in with the auto-detected ones.
45
46 module_build_options
47 Returns the correct options to the constructor of "Module::Build".
48 These are:
49
50 extra_compiler_flags
51 extra_linker_flags
52 config => { cc => ... }, # as of 0.15
53
54 Please note the above may have problems on Perl <= 5.8 with
55 ExtUtils::CBuilder <= 0.280230 due to a Perl RE issue.
56
57 makemaker_options
58 Returns the correct options to the "WriteMakefile" function of
59 "ExtUtils::MakeMaker". These are:
60
61 CCFLAGS
62 dynamic_lib => { OTHERLDFLAGS => ... }
63 CC # as of 0.15
64
65 If you specify the extra compiler or linker flags in the constructor,
66 they'll be merged into "CCFLAGS" or "OTHERLDFLAGS" respectively.
67
68 is_gcc
69 Returns true if the detected compiler is in the gcc family.
70
71 is_msvc
72 Returns true if the detected compiler is in the MS VC family.
73
74 is_clang
75 Returns true if the detected compiler is in the Clang family.
76
77 is_sunstudio
78 Returns true if the detected compiler is in the Sun Studio family.
79
80 add_extra_compiler_flags
81 Takes a string as argument that is added to the string of extra
82 compiler flags.
83
84 add_extra_linker_flags
85 Takes a string as argument that is added to the string of extra linker
86 flags.
87
88 compiler_command
89 Returns the string that can be passed to "system" to execute the
90 compiler. Will include the flags returned as the Module::Build
91 "extra_compiler_flags".
92
93 Added in 0.13.
94
95 linker_flags
96 The same as returned as the Module::Build "extra_linker_flags".
97
98 Added in 0.13.
99
100 iostream_fname
101 Returns the filename to "#include" to get iostream capability.
102
103 This can be used a bit creatively to be portable in one's XS files, as
104 the tests for this module need to be:
105
106 # in Makefile.PL:
107 $guess->add_extra_compiler_flags(
108 '-DINCLUDE_DOT=' .
109 ($guess->iostream_fname =~ /\./ ? 1 : 0)
110 );
111
112 // in your .xs file:
113 #if INCLUDE_DOT
114 #include <string.h>
115 #else
116 #include <string>
117 #endif
118
119 Added in 0.15.
120
121 cpp_flavor_defs
122 Returns the text for a header that "#define"s
123 "__INLINE_CPP_STANDARD_HEADERS" and "__INLINE_CPP_NAMESPACE_STD" if the
124 standard headers and namespace are available. This is determined by
125 trying to compile C++ with "#define <iostream>" - if it succeeds, the
126 symbols will be defined, else commented.
127
128 Added in 0.15.
129
131 Mattia Barbon <mbarbon@cpan.org>
132
133 Steffen Mueller <smueller@cpan.org>
134
135 Tobias Leich <froggs@cpan.org>
136
138 Copyright 2010, 2011 by Mattia Barbon.
139
140 This program is free software; you can redistribute it and/or modify it
141 under the same terms as Perl itself.
142
143
144
145perl v5.30.1 2020-02-17 ExtUtils::CppGuess(3)