Compiler object (compiler
)
This object is returned by meson.get_compiler()
.
It represents a compiler for a given language and allows you to query its properties.
Returned by
Compiler object objects are returned by the following functions and methods:
These compiler checks do not use compiler arguments added
with add_*_arguments()
, via -Dlang_args
on the command-line, or
through CFLAGS
/LDFLAGS
, etc in the environment. Hence, you can
trust that the tests will be fully self-contained, and won't fail
because of custom flags added by other parts of the build file or by
users.
Note that if you have a single prefix with all your dependencies, you
might find it easier to append to the environment variables
C_INCLUDE_PATH
with GCC/Clang and INCLUDE
with MSVC to expand the
default include path, and LIBRARY_PATH
with GCC/Clang and LIB
with
MSVC to expand the default library search path.
However, with GCC, these variables will be ignored when cross-compiling. In that case you need to use a specs file. See: http://www.mingw.org/wiki/SpecsFileHOWTO
Compiler object methods
compiler.alignment()
Returns the alignment of the specified type. For C-like languages,
For C-like languages, the header stddef.h
and stdio.h
are included
implicitly for native compilation, only stddef.h
is included when
cross-compiling.
Signature
# Returns the alignment of the specified type
int alignment(
str typename, # The name of the type to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
prefix : str | list[str] # Used to add `#include`s and other things that are required
)
Arguments
The method compiler.alignment()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
typename |
str |
The name of the type to check. |
|
Finally, compiler.alignment()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
prefix |
str | list [str ] |
Used to add |
|
compiler.check_header()
Returns true if the specified header is usable with the specified prefix, dependencies, and arguments.
Signature
(since 0.47.0)
# Returns true if the specified header is *usable*
bool check_header(
str header_name, # The header to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
prefix : str | list[str] # Used to add `#include`s and other things that are required
required : bool | feature # When set to `true`, Meson will halt if the header check fails
)
Arguments
The method compiler.check_header()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
header_name |
str |
The header to check. |
|
Finally, compiler.check_header()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
no_builtin_args |
bool |
When set to |
|
prefix |
str | list [str ] |
Used to add |
|
required |
bool | feature
|
When set to |
(since 0.50.0)
|
compiler.cmd_array()
Returns an array containing the command(s) for the compiler.
Signature
list[str] cmd_array()
compiler.compiles()
Returns true if the code compiles.
Signature
# Returns true if the code compiles
bool compiles(
str | file code, # The source code to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
name : str # The name to use for printing a message about the compiler check
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
required : bool | feature # When set to `true`, Meson will halt if the check fails
werror : bool # When set to `true`, compiler warnings are treated as error
)
Arguments
The method compiler.compiles()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
code |
str | file
|
The source code to check. If a string is passed, the code is used directly. If a |
|
Finally, compiler.compiles()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
name |
str |
The name to use for printing a message about the compiler check. If this keyword argument is not passed, no message will be printed about the check. |
|
no_builtin_args |
bool |
When set to |
|
required |
bool | feature
|
When set to |
(since 1.5.0)
|
werror |
bool |
When set to |
(since 1.3.0)
|
compiler.compute_int()
Computes the value of the given expression
(as an example 1 + 2
). When cross compiling this is evaluated with
an iterative algorithm, you can specify keyword arguments low
(defaults to -1024), high
(defaults to 1024) and guess
to
specify max and min values for the search and the value to try
first.
For C-like languages, the header stddef.h
and stdio.h
are included
implicitly for native compilation, only stddef.h
is included when
cross-compiling.
Signature
(since 0.40.0)
# Computes the value of the given expression
int compute_int(
str expr, # The expression to compute
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
guess : int # The value to try first
high : int # The max value
include_directories : inc | list[inc] # Extra directories for header searches
low : int # The min value
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
prefix : str | list[str] # Used to add `#include`s and other things that are required
)
Arguments
The method compiler.compute_int()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
expr |
str |
The expression to compute. |
|
Finally, compiler.compute_int()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
guess |
int |
The value to try first. |
|
high |
int |
The max value. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
low |
int |
The min value. |
|
no_builtin_args |
bool |
When set to |
|
prefix |
str | list [str ] |
Used to add |
|
compiler.find_library()
Tries to find the library specified in the positional argument.
Signature
# Tries to find the library specified in the positional argument
dep find_library(
str libname, # The library to find
# Keyword arguments:
dirs : list[str] # Additional directories to search in
disabler : bool # If `true`, this method will return a disabler
on a failed check.
has_headers : list[str] # List of headers that must be found as well
header_args : list[str] # When the `has_headers` kwarg is also used, this argument is passed to
header_dependencies : dep | list[dep] # When the `has_headers` kwarg is also used, this argument is passed to
header_include_directories : inc | list[inc] # When the `has_headers` kwarg is also used, this argument is passed to
header_no_builtin_args : bool # When the `has_headers` kwarg is also used, this argument is passed to
header_prefix : str # When the `has_headers` kwarg is also used, this argument is passed to
required : bool | feature # If set `true`, Meson will abort with an error if the library could not
static : bool # If `true`, the search is limited to static libraries only
)
Arguments
The method compiler.find_library()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
libname |
str |
The library to find. |
|
Finally, compiler.find_library()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
dirs |
list [str ] |
Additional directories to search in. By default the library is searched for in the system library directory (e.g. /usr/lib). Specifying more directories here, causes Meson to search in those directories as well as the system directories. |
|
disabler |
bool |
If |
(since 0.49.0)
|
has_headers |
list [str ] |
List of headers that must be found as well.
This check is equivalent to checking each header with a
When used, kwargs that |
(since 0.50.0) |
header_args |
list [str ] |
When the |
(since 0.51.0) |
header_dependencies |
dep | list [dep ] |
When the |
(since 0.51.0) |
header_include_directories |
inc | list [inc ] |
When the |
(since 0.51.0) |
header_no_builtin_args |
bool |
When the |
(since 0.51.0)
|
header_prefix |
str |
When the |
(since 0.51.0) |
required |
bool | feature
|
If set When set to a (since 0.47.0) The value of a |
|
static |
bool |
If |
(since 0.51.0)
|
compiler.first_supported_argument()
Given a list of strings, returns a single-element list containing the first
argument that passes the compiler.has_argument()
test or an empty array if
none pass.
Signature
(since 0.43.0)
# Given a list of strings, returns a single-element list containing the first
list[str] first_supported_argument(
str arg..., # The arguments to check
)
Arguments
The
method accepts between 0
and infinity
variadic
arguments (arg...
) of type
.str
The arguments to check.
compiler.first_supported_link_argument()
Given a list of strings, returns the first argument that passes the
compiler.has_link_argument()
test or an empty array if none pass.
Signature
(since 0.46.0)
# Given a list of strings, returns the first argument that passes the
list[str] first_supported_link_argument(
str arg..., # The link arguments to check
)
Arguments
The
method accepts between 0
and infinity
variadic
arguments (arg...
) of type
.str
The link arguments to check.
compiler.get_argument_syntax()
returns a string identifying the type of arguments the compiler takes.
Can be one of gcc
, msvc
, or an undefined
string value. This method is useful for identifying compilers that are not
gcc or msvc, but use the same argument syntax as one of those two compilers
such as clang or icc, especially when they use different syntax on different
operating systems.
Signature
(since 0.49.0)
str get_argument_syntax()
compiler.get_define()
Returns the given preprocessor symbol's value as a string or empty string if it is not defined.
(since 0.47.0) This method will concatenate string literals as
the compiler would. E.g. "a" "b"
will become "ab"
.
Signature
(since 0.40.0)
# Returns the given preprocessor symbol's value
str get_define(
str definename, # The define to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
prefix : str | list[str] # Used to add `#include`s and other things that are required
)
Arguments
The method compiler.get_define()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
definename |
str |
The define to check. |
|
Finally, compiler.get_define()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
no_builtin_args |
bool |
When set to |
|
prefix |
str | list [str ] |
Used to add |
|
compiler.get_id()
Returns a string identifying the compiler.
For example, gcc
, msvc
, and more.
Signature
str get_id()
compiler.get_linker_id()
Returns a string identifying the linker.
For example, ld.bfd
, link
, and more.
Signature
(since 0.53.0)
str get_linker_id()
compiler.get_supported_arguments()
Returns an array containing only the arguments supported by the compiler,
as if compiler.has_argument()
were called on them individually.
Signature
(since 0.43.0)
# Returns an array containing only the arguments supported by the compiler,
list[str] get_supported_arguments(
str arg..., # The arguments to check
# Keyword arguments:
checked : str # Supported values:
)
Arguments
The
method accepts between 0
and infinity
variadic
arguments (arg...
) of type
.str
The arguments to check.
The method compiler.get_supported_arguments()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
checked |
str |
Supported values:
|
(since 0.59.0)
|
compiler.get_supported_function_attributes()
Returns an array containing any names that are supported GCC style attributes.
Equivalent to compiler.has_function_attribute()
was called on each of
them individually.
Signature
(since 0.48.0)
list[str] get_supported_function_attributes()
compiler.get_supported_link_arguments()
Returns an array containing only the arguments supported by the compiler,
as if compiler.has_link_argument()
were called on them individually.
Signature
(since 0.46.0)
# Returns an array containing only the arguments supported by the compiler,
list[str] get_supported_link_arguments(
str arg..., # The link arguments to check
)
Arguments
The
method accepts between 0
and infinity
variadic
arguments (arg...
) of type
.str
The link arguments to check.
compiler.has_argument()
Returns true
if the compiler accepts the specified command line argument,
that is, can compile code without erroring out or printing a warning about
an unknown flag.
Signature
# Returns `true` if the compiler accepts the specified command line argument,
bool has_argument(
str argument, # The argument to check
# Keyword arguments:
required : bool | feature # When set to `true`, Meson will halt if the check fails
)
Arguments
The method compiler.has_argument()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
argument |
str |
The argument to check. |
|
Finally, compiler.has_argument()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
required |
bool | feature
|
When set to |
(since 1.3.0)
|
compiler.has_define()
Returns true if the given preprocessor symbol is defined.
Signature
(since 1.3.0)
# Returns true if the given preprocessor symbol is *defined*
bool has_define(
str definename, # The define to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
prefix : str | list[str] # Used to add `#include`s and other things that are required
)
Arguments
The method compiler.has_define()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
definename |
str |
The define to check. |
|
Finally, compiler.has_define()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
no_builtin_args |
bool |
When set to |
|
prefix |
str | list [str ] |
Used to add |
|
compiler.has_function()
Returns true if the given function is provided
by the standard library or a library passed in with the args
keyword.
Signature
# Returns true if the given function is provided
bool has_function(
str funcname, # The function to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
prefix : str | list[str] # Used to add `#include`s and other things that are required
required : bool | feature # When set to `true`, Meson will halt if the check fails
)
Arguments
The method compiler.has_function()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
funcname |
str |
The function to check. |
|
Finally, compiler.has_function()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
no_builtin_args |
bool |
When set to |
|
prefix |
str | list [str ] |
Used to add |
|
required |
bool | feature
|
When set to |
(since 1.3.0)
|
compiler.has_function_attribute()
Returns true
if the compiler supports the GNU style (__attribute__(...)
) name
.
This is preferable to manual compile checks as it may be optimized for compilers that
do not support such attributes.
This table lists all of the supported attributes.
Signature
(since 0.48.0)
# Returns `true` if the compiler supports the GNU style (`__attribute__(
bool has_function_attribute(
str name, # The attribute name to check
# Keyword arguments:
required : bool | feature # When set to `true`, Meson will halt if the check fails
)
Arguments
The method compiler.has_function_attribute()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
name |
str |
The attribute name to check. |
|
Finally, compiler.has_function_attribute()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
required |
bool | feature
|
When set to |
(since 1.3.0)
|
compiler.has_header()
Returns true if the specified header is exists with the specified prefix, dependencies, and arguments.
This method is faster than compiler.check_header()
since it only does a
pre-processor check.
Signature
# Returns true if the specified header is *exists*
bool has_header(
str header_name, # The header to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
prefix : str | list[str] # Used to add `#include`s and other things that are required
required : bool | feature # When set to `true`, Meson will halt if the header check fails
)
Arguments
The method compiler.has_header()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
header_name |
str |
The header to check. |
|
Finally, compiler.has_header()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
no_builtin_args |
bool |
When set to |
|
prefix |
str | list [str ] |
Used to add |
|
required |
bool | feature
|
When set to |
(since 0.50.0)
|
compiler.has_header_symbol()
Detects whether a particular symbol is declared in the specified header.
Symbols here include function, variable, #define
, type definition, etc.
Signature
# Detects whether a particular symbol is declared in the specified header
bool has_header_symbol(
str header, # The header to check
str symbol, # The symbol to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
prefix : str | list[str] # Used to add `#include`s and other things that are required
required : bool | feature # When set to `true`, Meson will halt if the header check fails
)
Arguments
The method compiler.has_header_symbol()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
header |
str |
The header to check. |
|
symbol |
str |
The symbol to check. |
|
Finally, compiler.has_header_symbol()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
no_builtin_args |
bool |
When set to |
|
prefix |
str | list [str ] |
Used to add |
|
required |
bool | feature
|
When set to |
(since 0.50.0)
|
compiler.has_link_argument()
Returns true
if the linker accepts the specified command line argument,
that is, can
compile and link code without erroring out or printing a warning
about an unknown flag. Link arguments will be passed to the
compiler, so should usually have the -Wl,
prefix. On VisualStudio
a /link
argument will be prepended.
Signature
(since 0.46.0)
# Returns `true` if the linker accepts the specified command line argument,
bool has_link_argument(
str argument, # The argument to check
# Keyword arguments:
required : bool | feature # When set to `true`, Meson will halt if the check fails
)
Arguments
The method compiler.has_link_argument()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
argument |
str |
The argument to check. |
|
Finally, compiler.has_link_argument()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
required |
bool | feature
|
When set to |
(since 1.3.0)
|
compiler.has_member()
Returns true if the type has the specified member.
Signature
# Returns true if the type has the specified member
bool has_member(
str typename, # The type to check
str membername, # The member to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
prefix : str | list[str] # Used to add `#include`s and other things that are required
required : bool | feature # When set to `true`, Meson will halt if the check fails
)
Arguments
The method compiler.has_member()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
typename |
str |
The type to check. |
|
membername |
str |
The member to check. |
|
Finally, compiler.has_member()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
no_builtin_args |
bool |
When set to |
|
prefix |
str | list [str ] |
Used to add |
|
required |
bool | feature
|
When set to |
(since 1.3.0)
|
compiler.has_members()
Returns true
if the type has all the specified members.
Signature
# Returns `true` if the type has *all* the specified members
bool has_members(
str typename, # The type to check
str member..., # The members to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
prefix : str | list[str] # Used to add `#include`s and other things that are required
required : bool | feature # When set to `true`, Meson will halt if the check fails
)
Arguments
The method compiler.has_members()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
typename |
str |
The type to check. |
|
Additionally, the
method accepts between 1
and infinity
variadic
arguments (member...
) of type
.str
The members to check
Finally, compiler.has_members()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
no_builtin_args |
bool |
When set to |
|
prefix |
str | list [str ] |
Used to add |
|
required |
bool | feature
|
When set to |
(since 1.3.0)
|
compiler.has_multi_arguments()
the same as compiler.has_argument()
but takes multiple arguments
and uses them all in a single compiler invocation.
Signature
(since 0.37.0)
# the same as compiler.has_argument()
but takes multiple arguments
bool has_multi_arguments(
str arg..., # The arguments to check
# Keyword arguments:
required : bool | feature # When set to `true`, Meson will halt if the check fails
)
Arguments
The
method accepts between 0
and infinity
variadic
arguments (arg...
) of type
.str
The arguments to check.
The method compiler.has_multi_arguments()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
required |
bool | feature
|
When set to |
(since 1.3.0)
|
compiler.has_multi_link_arguments()
the same as compiler.has_link_argument()
but takes multiple arguments
and uses them all in a single compiler invocation.
Signature
(since 0.46.0)
# the same as compiler.has_link_argument()
but takes multiple arguments
bool has_multi_link_arguments(
str arg..., # The link arguments to check
# Keyword arguments:
required : bool | feature # When set to `true`, Meson will halt if the check fails
)
Arguments
The
method accepts between 0
and infinity
variadic
arguments (arg...
) of type
.str
The link arguments to check.
The method compiler.has_multi_link_arguments()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
required |
bool | feature
|
When set to |
(since 1.3.0)
|
compiler.has_type()
Returns true
if the specified token is a type.
Signature
# Returns `true` if the specified token is a type
bool has_type(
str typename, # The type to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
prefix : str | list[str] # Used to add `#include`s and other things that are required
required : bool | feature # When set to `true`, Meson will halt if the check fails
)
Arguments
The method compiler.has_type()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
typename |
str |
The type to check. |
|
Finally, compiler.has_type()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
no_builtin_args |
bool |
When set to |
|
prefix |
str | list [str ] |
Used to add |
|
required |
bool | feature
|
When set to |
(since 1.3.0)
|
compiler.links()
Returns true if the code compiles and links.
Since 0.60.0, if the file
object's
suffix does not match the compiler object's language, the compiler
corresponding to the suffix is used to compile the source, while the
target of the links
method is used to link the resulting object file.
Signature
# Returns true if the code compiles and links
bool links(
str | file code, # The source code to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
name : str # The name to use for printing a message about the compiler check
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
required : bool | feature # When set to `true`, Meson will halt if the check fails
werror : bool # When set to `true`, compiler warnings are treated as error
)
Arguments
The method compiler.links()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
code |
str | file
|
The source code to check. If a string is passed, the code is used directly. If a |
|
Finally, compiler.links()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
name |
str |
The name to use for printing a message about the compiler check. If this keyword argument is not passed, no message will be printed about the check. |
|
no_builtin_args |
bool |
When set to |
|
required |
bool | feature
|
When set to |
(since 1.5.0)
|
werror |
bool |
When set to |
(since 1.3.0)
|
compiler.preprocess()
Preprocess a list of source files but do not compile them. The preprocessor
will receive the same arguments (include directories, defines, etc) as with
normal compilation. That includes for example args added with
add_project_arguments()
, or on the command line with -Dc_args=-DFOO
.
Signature
(since 0.64.0)
# Preprocess a list of source files but do not compile them
list[custom_idx] preprocess(
str | file | custom_tgt | custom_idx | generated_list source..., # Input source to preprocess
# Keyword arguments:
compile_args : list[str] # Extra flags to pass to the preprocessor
dependencies : dep | list[dep] # Additionally dependencies required
depends : list[build_tgt | custom_tgt] # Specifies that this target depends on the specified
include_directories : inc | list[inc] # Extra directories for header searches
output : str # Template for name of preprocessed files: `@PLAINNAME@` is replaced by
)
Arguments
The
method accepts between 0
and infinity
variadic
arguments (source...
) of type
.str
| file
| custom_tgt
| custom_idx
| generated_list
Input source to preprocess. The following types are supported:
-
Strings relative to the current source directory
-
file
objects defined in any preceding build file -
The return value of configure-time generators such as
configure_file()
-
The return value of build-time generators such as
custom_target()
orgenerator.process()
The method
compiler.preprocess()
accepts the following keyword arguments:Name Type Description Tags compile_args
list
[str
]Extra flags to pass to the preprocessor
dependencies
dep
|list
[dep
]Additionally dependencies required.
(since 1.1.0)
depends
list
[build_tgt
|custom_tgt
]Specifies that this target depends on the specified target(s). These targets should be built before starting to preprocess an input.
(since 1.4.0)
include_directories
inc
|list
[inc
]Extra directories for header searches.
(since 0.38.0)
output
str
Template for name of preprocessed files:
@PLAINNAME@
is replaced by the source filename and@BASENAME@
is replaced by the source filename without its extension.
compiler.run()
Attempts to compile and execute the given code fragment.
Signature
# Attempts to compile and execute the given code fragment
runresult run(
str | file code, # The source code to check
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
name : str # The name to use for printing a message about the compiler check
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
required : bool | feature # When set to `true`, Meson will halt if the check fails
werror : bool # When set to `true`, compiler warnings are treated as error
)
Arguments
The method compiler.run()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
code |
str | file
|
The source code to check. If a string is passed, the code is used directly. If a |
|
Finally, compiler.run()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
name |
str |
The name to use for printing a message about the compiler check. If this keyword argument is not passed, no message will be printed about the check. |
|
no_builtin_args |
bool |
When set to |
|
required |
bool | feature
|
When set to |
(since 1.5.0)
|
werror |
bool |
When set to |
(since 1.3.0)
|
compiler.sizeof()
returns the size of the given type (e.g. 'int'
) or -1 if the type is unknown.
For C-like languages, the header stddef.h
and stdio.h
are included
implicitly for native compilation, only stddef.h
is included when
cross-compiling.
Signature
# returns the size of the given type (e
int sizeof(
str typename, # The type to compute
# Keyword arguments:
args : list[str] # Used to pass a list of compiler arguments
dependencies : dep | list[dep] # Additionally dependencies required for compiling and / or linking
include_directories : inc | list[inc] # Extra directories for header searches
no_builtin_args : bool # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
prefix : str | list[str] # Used to add `#include`s and other things that are required
)
Arguments
The method compiler.sizeof()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
typename |
str |
The type to compute. |
|
Finally, compiler.sizeof()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
args |
list [str ] |
Used to pass a list of compiler arguments.
Defining include paths for headers not in the default include path
via This is because include directories can also be specified via the
|
|
dependencies |
dep | list [dep ] |
Additionally dependencies required for compiling and / or linking. |
|
include_directories |
inc | list [inc ] |
Extra directories for header searches. |
(since 0.38.0) |
no_builtin_args |
bool |
When set to |
|
prefix |
str | list [str ] |
Used to add |
|
compiler.symbols_have_underscore_prefix()
Returns true
if the C symbol mangling is one underscore (_
) prefixed to the symbol.
Signature
(since 0.37.0)
bool symbols_have_underscore_prefix()
compiler.version()
Returns the compiler's version number as a string.
Signature
str version()
The results of the search are