---
name: "Dist::Build::XS::WriteConstants"
section: "3pm"
platform: "linux"
package: "libdist-build-perl"
version: "0.020-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Dist::Build::XS::WriteConstants"
---

# Dist::Build::XS::WriteConstants(3pm)

Dist::Build extension integrating ExtUtils::Constant

## NAME

Dist::Build::XS::WriteConstants - Dist::Build extension integrating ExtUtils::Constant

## VERSION

version 0.020

## SYNOPSIS

```
 load_extension('Dist::Build::XS');
 load_extension('Dist::Build::XS::WriteConstants');
 add_xs(
     module          => 'Foo::Bar',
     write_constants => {
         NAMES => [ qw/FOO BAR BAZ/ ],
     },
 );
```

## DESCRIPTION

This module is an extension of Dist::Build::XS, adding an additional argument to the `"add_xs"` function: `"write_constants"`. This hash will take the same members as the `"WriteConstants"` function of ExtUtils::Constant, except that it will set sensible default values for the `"NAME"` (based on the module's name), `"C_FILE"` and `"XS_FILE"` (based on the XS file's directory and `"CONST_BASENAME"` defaulting to `'const'`) members so usually those will not need to be passed. So the above example is equivalent to

```
  {
    NAME    => 'Foo::Bar',
    NAMES   => [ qw/FOO BAR BAZ/ ],
    C_FILE  => 'lib/Foo/const-c.inc',
    XS_FILE => 'lib/Foo/const-xs.inc',
  }
```

## AUTHOR

Leon Timmermans \<fawaka@gmail.com\>

## COPYRIGHT AND LICENSE

This software is copyright (c) 2024 by Leon Timmermans.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
