Skip to content

Commit f87f59c

Browse files
authored
Merge pull request #2 from cpp-gamedev/1-basic-process-facilities
process, exit() functionality
2 parents f073f02 + dea772c commit f87f59c

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ endif()
1313
if(MSVC)
1414
string(REPLACE "/RTC1" "" OLD_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}")
1515
set(CMAKE_CXX_FLAGS_DEBUG "${OLD_FLAGS}")
16-
add_compile_options(/permissive- /Zc:preprocessor /JMC /std:c++latest /Za /GR- /GS- /EHsc-)
16+
add_compile_options(/permissive- /Zc:preprocessor /JMC /std:c++latest /GR- /GS- /EHsc-)
1717
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1818
add_compile_options(-ffreestanding -nostdinc++ -fno-exceptions -fno-rtti)
1919
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

starlib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ target_sources(starlib
88
process.ixx
99
PRIVATE
1010
starlib.cpp
11+
process.cpp
1112
"process.ixx")
1213

1314
target_include_directories(starlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

starlib/process.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module;
2+
#ifdef _WIN32
3+
#include <Windows.h>
4+
#else
5+
#error Unsupported platform
6+
#endif
7+
8+
module process;
9+
10+
void starlib::process::Exit(int code)
11+
{
12+
#ifdef _WIN32
13+
ExitProcess(static_cast<UINT>(code));
14+
#else
15+
#error Unsupported platform
16+
#endif
17+
}

starlib/process.ixx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export module process;
2+
3+
namespace starlib::process
4+
{
5+
export [[noreturn]] void Exit(int code);
6+
}

starlib/starlib.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module starlib;
22

3-
int starlib::Meow(void)
3+
extern "C" void DefaultMain(void)
44
{
5-
return 1234;
5+
starlib::process::Exit(1);
66
}
77

88
extern "C" void DefaultMain(void)

starlib/starlib.ixx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
export module starlib;
22

3-
namespace starlib
4-
{
5-
export int Meow();
6-
}
3+
export import process;

testing/main.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
import starlib;
22

3-
int main(void)
4-
{
5-
return starlib::Meow();
6-
}

0 commit comments

Comments
 (0)