samples: Rename helloworld_std_thread to helloworld_cpp.

This commit is contained in:
James Benton 2018-06-13 17:35:03 +01:00
parent adfd1c4e91
commit 4026ad081a
4 changed files with 43 additions and 22 deletions

View File

@ -5,7 +5,7 @@ include("${WUT_ROOT}/share/wut.cmake" REQUIRED)
add_subdirectory(custom_default_heap)
add_subdirectory(gx2_triangle)
add_subdirectory(helloworld)
add_subdirectory(helloworld_std_thread)
add_subdirectory(helloworld_cpp)
add_subdirectory(my_first_rpl)
add_subdirectory(swkbd)

View File

@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.2)
project(helloworld_cpp CXX)
include("${WUT_ROOT}/share/wut.cmake" REQUIRED)
add_executable(helloworld_cpp
main.cpp)
target_link_libraries(helloworld_cpp
whb
coreinit
proc_ui
sysapp
nn_ac)
wut_enable_newlib(helloworld_cpp)
wut_enable_stdcpp(helloworld_cpp)
wut_create_rpx(helloworld_cpp.rpx
helloworld_cpp)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/helloworld_cpp.rpx"
DESTINATION "${CMAKE_INSTALL_PREFIX}")

View File

@ -1,6 +1,7 @@
#include <coreinit/thread.h>
#include <coreinit/time.h>
#include <coreinit/systeminfo.h>
#include <nn/ac.h>
#include <whb/proc.h>
#include <whb/log.h>
@ -12,8 +13,19 @@ int
hello_thread()
{
int last_tm_sec = -1;
uint32_t ip = 0;
WHBLogPrintf("Hello World from a std::thread!");
if (!nn::ac::GetAssignedAddress(&ip)) {
WHBLogPrintf("GetAssignedAddress failed!");
}
WHBLogPrintf("My IP is: %u.%u.%u.%u",
(ip >> 24) & 0xFF,
(ip >> 16) & 0xFF,
(ip >> 8) & 0xFF,
(ip >> 0) & 0xFF);
while(WHBProcIsRunning()) {
OSCalendarTime tm;
OSTicksToCalendarTime(OSGetTime(), &tm);
@ -38,6 +50,12 @@ hello_thread()
int
main(int argc, char **argv)
{
nn::ac::ConfigIdNum configId;
nn::ac::Initialize();
nn::ac::GetStartupId(&configId);
nn::ac::Connect(configId);
WHBProcInit();
WHBLogConsoleInit();
@ -46,5 +64,7 @@ main(int argc, char **argv)
WHBLogConsoleFree();
WHBProcShutdown();
nn::ac::Finalize();
return 0;
}

View File

@ -1,21 +0,0 @@
cmake_minimum_required(VERSION 3.2)
project(helloworld_std_thread CXX)
include("${WUT_ROOT}/share/wut.cmake" REQUIRED)
add_executable(helloworld_std_thread
main.cpp)
target_link_libraries(helloworld_std_thread
whb
coreinit
proc_ui
sysapp)
wut_enable_newlib(helloworld_std_thread)
wut_enable_stdcpp(helloworld_std_thread)
wut_create_rpx(helloworld_std_thread.rpx
helloworld_std_thread)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/helloworld_std_thread.rpx"
DESTINATION "${CMAKE_INSTALL_PREFIX}")