Name

SPVM::Sys::OS - OS Information

Description

Sys::OS class in SPVM has methods to get OS information.

Usage

use Sys::OS;

my $is_windows = Sys::OS->defined("_WIN32");

my $is_windows = Sys::OS->is_windows;

Class Methods

defined

static method defined : int ($macro_name : string, $value_ref : object of int[]|long[]|double[] = undef);

Checks if the macro $macro_name is defined on the system. If the macro is defined, returns 1, otherwise returns 0.

If $value_ref is given, the macro value is set to the first element of $value_ref.

The following macro names are supported.

  • __GNUC__

  • __clang__

  • __BORLANDC__

  • __INTEL_COMPILER

  • __unix

  • __unix__

  • __linux

  • __linux__

  • __FreeBSD__

  • __NetBSD__

  • __OpenBSD__

  • _WIN32

  • WIN32

  • _WIN64

  • _WINDOWS

  • _CONSOLE

  • WINVER

  • _WIN32_WINDOWS

  • _WIN32_WINNT

  • WINCEOSVER

  • __CYGWIN__

  • __CYGWIN32__

  • __MINGW32__

  • __MINGW64__

  • __APPLE__

  • __MACH__

  • __sun

  • __solaris

Exceptions:

$value_ref must be the int[], long[], or double[] type. Otherwise an exception is thrown.

If the macro name is not supported, an exception is thrown.

is_windows

static method is_windows : int ();

If the OS is Windows(_WIN32 is defined), returns 1, otherwise returns 0.

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License