Shows how to use xtd::environment::exit_code method.
#include <xtd/console>
#include <xtd/environment>
#include <xtd/startup>
namespace environment_exit_code_example {
class program {
public:
static auto main() {
auto args = environment::get_command_line_args();
if (args.size() == 1)
environment::exit_code(ECANCELED);
else {
auto value = 0l;
if (try_parse(args[1], value))
if (value <= std::numeric_limits<int>::min() || value >= std::numeric_limits<int>::max())
environment::exit_code(ERANGE);
else
console::write_line("Result: {0}", value * 2);
else
environment::exit_code(EINVAL);
}
}
};
}
startup_(environment_exit_code_example::program::main);
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:175
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10