1ExtUtils::CppGuess(3) User Contributed Perl DocumentationExtUtils::CppGuess(3)
2
3
4

NAME

6       ExtUtils::CppGuess - guess C++ compiler and flags
7

SYNOPSIS

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

DESCRIPTION

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

ENVIRONMENT

38       As of 0.24, the environment variable "CXX" defines the obvious value,
39       and will be used instead of any detection.  Supplied arguments to "new"
40       will still win.
41

METHODS

43   new
44       Creates a new "ExtUtils::CppGuess" object.  Takes the path to the C
45       compiler as the "cc" argument, but falls back to the value of
46       $Config{cc}, which should be what you want anyway.
47
48       You can specify "extra_compiler_flags" and "extra_linker_flags" (as
49       strings) which will be merged in with the auto-detected ones.
50
51   module_build_options
52       Returns the correct options to the constructor of "Module::Build".
53       These are:
54
55           extra_compiler_flags
56           extra_linker_flags
57           config => { cc => ... }, # as of 0.15
58
59       Please note the above may have problems on Perl <= 5.8 with
60       ExtUtils::CBuilder <= 0.280230 due to a Perl RE issue.
61
62   makemaker_options
63       Returns the correct options to the "WriteMakefile" function of
64       "ExtUtils::MakeMaker".  These are:
65
66           CCFLAGS
67           dynamic_lib => { OTHERLDFLAGS => ... }
68           CC # as of 0.15
69
70       If you specify the extra compiler or linker flags in the constructor,
71       they'll be merged into "CCFLAGS" or "OTHERLDFLAGS" respectively.
72
73   is_gcc
74       Returns true if the detected compiler is in the gcc family.
75
76   is_msvc
77       Returns true if the detected compiler is in the MS VC family.
78
79   is_clang
80       Returns true if the detected compiler is in the Clang family.
81
82   is_sunstudio
83       Returns true if the detected compiler is in the Sun Studio family.
84
85   add_extra_compiler_flags
86       Takes a string as argument that is added to the string of extra
87       compiler flags.
88
89   add_extra_linker_flags
90       Takes a string as argument that is added to the string of extra linker
91       flags.
92
93   compiler_command
94       Returns the string that can be passed to "system" to execute the
95       compiler.  Will include the flags returned as the Module::Build
96       "extra_compiler_flags".
97
98       Added in 0.13.
99
100   linker_flags
101       The same as returned as the Module::Build "extra_linker_flags".
102
103       Added in 0.13.
104
105   iostream_fname
106       Returns the filename to "#include" to get iostream capability.
107
108       This can be used a bit creatively to be portable in one's XS files, as
109       the tests for this module need to be:
110
111         # in Makefile.PL:
112         $guess->add_extra_compiler_flags(
113           '-DINCLUDE_DOT=' .
114           ($guess->iostream_fname =~ /\./ ? 1 : 0)
115         );
116
117         // in your .xs file:
118         #if INCLUDE_DOT
119         #include <string.h>
120         #else
121         #include <string>
122         #endif
123
124       Added in 0.15.
125
126   cpp_flavor_defs
127       Returns the text for a header that "#define"s
128       "__INLINE_CPP_STANDARD_HEADERS" and "__INLINE_CPP_NAMESPACE_STD" if the
129       standard headers and namespace are available. This is determined by
130       trying to compile C++ with "#define <iostream>" - if it succeeds, the
131       symbols will be defined, else commented.
132
133       Added in 0.15.
134
135   cpp_standard_flag
136         $guess->cpp_standard_flag( $standard_name )
137
138       Given a string $standard_name that is currently one of
139
140       •   "C++98"
141
142       •   "C++11"
143
144       •   "C++14"
145
146       •   "C++17"
147
148       returns a string with a flag that can be used to tell the compiler to
149       support that version of the C++ standard or dies if version is not
150       supported.
151
152       Added in version v0.22.
153

AUTHOR

155       Mattia Barbon <mbarbon@cpan.org>
156
157       Steffen Mueller <smueller@cpan.org>
158
159       Tobias Leich <froggs@cpan.org>
160
162       Copyright 2010, 2011 by Mattia Barbon.
163
164       This program is free software; you can redistribute it and/or modify it
165       under the same terms as Perl itself.
166
167
168
169perl v5.38.0                      2023-07-20             ExtUtils::CppGuess(3)
Impressum