summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibMain/Main.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-22 15:44:54 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-22 19:28:31 +0100
commitd3cf68a5407a756e79a5b2f97303b855b7253e86 (patch)
treec682d881aa21bcdeeebd6c4056127113e49c9ebd /Userland/Libraries/LibMain/Main.h
parent317ceb0ee22ee4bceaad97773082a425f0694a94 (diff)
downloadserenity-d3cf68a5407a756e79a5b2f97303b855b7253e86.zip
LibMain: Add a new library for more ergonomic userspace entry functions
By linking with LibMain, your program no longer needs to provide main(). Instead, execution begins in this function: ErrorOr<int> serenity_main(Main::Arguments); This allows programs that link with LibMain to use TRY() already in their entry function, without having to do manual ErrorOr unwrapping. This is very experimental, but it seems like a nice idea so let's try it out. :^)
Diffstat (limited to 'Userland/Libraries/LibMain/Main.h')
-rw-r--r--Userland/Libraries/LibMain/Main.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/Userland/Libraries/LibMain/Main.h b/Userland/Libraries/LibMain/Main.h
new file mode 100644
index 0000000000..ee8e85b3cb
--- /dev/null
+++ b/Userland/Libraries/LibMain/Main.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Error.h>
+
+namespace Main {
+
+struct Arguments {
+ int argc {};
+ char** argv {};
+ Span<StringView> arguments;
+};
+
+}
+
+ErrorOr<int> serenity_main(Main::Arguments);