init
This commit is contained in:
commit
dbe96e7055
21
.devcontainer/Dockerfile
Normal file
21
.devcontainer/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# [Choice] Debian / Ubuntu version (use Debian 12, Debian 11, Ubuntu 22.04 on local arm64/Apple Silicon): debian-12, debian-11, debian-10, ubuntu-22.04, ubuntu-20.04
|
||||||
|
ARG VARIANT=debian-12
|
||||||
|
FROM mcr.microsoft.com/devcontainers/base:${VARIANT}
|
||||||
|
USER root
|
||||||
|
|
||||||
|
# Install needed packages. Use a separate RUN statement to add your own dependencies.
|
||||||
|
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||||
|
&& apt-get -y install build-essential cmake cppcheck valgrind clang lldb llvm gdb \
|
||||||
|
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# [Optional] Uncomment this section to install additional OS packages.
|
||||||
|
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||||
|
&& apt-get -y install --no-install-recommends \
|
||||||
|
mingw-w64 \
|
||||||
|
mingw-w64-i686-dev \
|
||||||
|
mingw-w64-x86-64-dev \
|
||||||
|
gdb-mingw-w64 \
|
||||||
|
gdb-mingw-w64-target \
|
||||||
|
clang-format \
|
||||||
|
ninja-build \
|
||||||
|
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
|
39
.devcontainer/devcontainer.json
Normal file
39
.devcontainer/devcontainer.json
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"name": "C++",
|
||||||
|
"build": {
|
||||||
|
"dockerfile": "Dockerfile"
|
||||||
|
},
|
||||||
|
"runArgs": [
|
||||||
|
"--cap-add=SYS_PTRACE",
|
||||||
|
"--security-opt",
|
||||||
|
"seccomp=unconfined"
|
||||||
|
],
|
||||||
|
"features": {
|
||||||
|
"ghcr.io/devcontainers/features/common-utils:2": {
|
||||||
|
"installZsh": "true",
|
||||||
|
"username": "vscode",
|
||||||
|
"userUid": "1000",
|
||||||
|
"userGid": "1000"
|
||||||
|
},
|
||||||
|
"ghcr.io/maks1ms/devcontainers-features/wine:0": {},
|
||||||
|
"ghcr.io/devcontainers/features/desktop-lite:1": {}
|
||||||
|
},
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"settings": {},
|
||||||
|
"extensions": [
|
||||||
|
"ms-vscode.cpptools-extension-pack",
|
||||||
|
"xaver.clang-format"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"forwardPorts": [
|
||||||
|
6080
|
||||||
|
],
|
||||||
|
"portsAttributes": {
|
||||||
|
"6080": {
|
||||||
|
"label": "desktop"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"remoteUser": "vscode"
|
||||||
|
}
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
build
|
||||||
|
depends
|
9
.vscode/cmake-kits.json
vendored
Normal file
9
.vscode/cmake-kits.json
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "GCC 8.3-posix (i686-w64-mingw32)",
|
||||||
|
"compilers": {
|
||||||
|
"C": "i686-w64-mingw32-gcc-posix",
|
||||||
|
"CXX": "i686-w64-mingw32-g++-posix"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "(gdb) Launch",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${command:cmake.launchTargetPath}",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "/usr/bin/i686-w64-mingw32-gdb",
|
||||||
|
"debugServerArgs": "Z:/usr/share/win32/gdbserver.exe localhost:1111 ${command:cmake.launchTargetPath} ${command:cmake.launchTargetPath} arg1 arg2",
|
||||||
|
"miDebuggerServerAddress": "localhost:1111",
|
||||||
|
"serverStarted":"Listening\\ on\\ port\\ \\d*",
|
||||||
|
"debugServerPath": "/usr/bin/wine",
|
||||||
|
"filterStderr":true,
|
||||||
|
"filterStdout":false,
|
||||||
|
"logging": {
|
||||||
|
"moduleLoad": true,
|
||||||
|
"programOutput": true,
|
||||||
|
"exceptions": true
|
||||||
|
},
|
||||||
|
"preLaunchTask": "pkill gdbserver",
|
||||||
|
"postDebugTask": "pkill gdbserver"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
64
.vscode/settings.json
vendored
Normal file
64
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"*.ts": "typescriptreact",
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"chrono": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"condition_variable": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"forward_list": "cpp",
|
||||||
|
"list": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"unordered_set": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"set": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"future": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"mutex": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"thread": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeinfo": "cpp",
|
||||||
|
"windows.h": "c"
|
||||||
|
}
|
||||||
|
}
|
15
.vscode/tasks.json
vendored
Normal file
15
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "pkill gdbserver",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "pkill gdbserver || true",
|
||||||
|
"group": "test",
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "never",
|
||||||
|
"panel": "shared"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
15
CMakeLists.txt
Normal file
15
CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
project(hello)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_SYSTEM_NAME Windows)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "-static -mwindows")
|
||||||
|
set(CMAKE_EXECUTABLE_SUFFIX ".exe")
|
||||||
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
|
||||||
|
|
||||||
|
add_executable(hello
|
||||||
|
src/main.c)
|
||||||
|
|
||||||
|
target_link_libraries(hello PRIVATE)
|
||||||
|
|
||||||
|
install(TARGETS hello DESTINATION bin)
|
91
src/main.c
Normal file
91
src/main.c
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#ifndef UNICODE
|
||||||
|
#define UNICODE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
|
||||||
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
|
||||||
|
{
|
||||||
|
HWND hwnd;
|
||||||
|
MSG msg;
|
||||||
|
WNDCLASSEX wcex;
|
||||||
|
|
||||||
|
wcex.cbSize = sizeof(wcex);
|
||||||
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
|
wcex.lpfnWndProc = WndProc;
|
||||||
|
wcex.cbClsExtra = 0;
|
||||||
|
wcex.cbWndExtra = 0;
|
||||||
|
wcex.hInstance = hInstance;
|
||||||
|
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||||
|
wcex.lpszMenuName = NULL;
|
||||||
|
wcex.lpszClassName = L"HelloWin";
|
||||||
|
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
|
||||||
|
RegisterClassEx(&wcex);
|
||||||
|
|
||||||
|
hwnd = CreateWindow(wcex.lpszClassName, // window class name
|
||||||
|
L"Hello World", // window caption
|
||||||
|
WS_OVERLAPPEDWINDOW, // window style
|
||||||
|
CW_USEDEFAULT, // initial x position
|
||||||
|
CW_USEDEFAULT, // initial y position
|
||||||
|
CW_USEDEFAULT, // initial x size
|
||||||
|
CW_USEDEFAULT, // initial y size
|
||||||
|
NULL, // parent window handle
|
||||||
|
NULL, // window menu handle
|
||||||
|
hInstance, // program instance handle
|
||||||
|
NULL); // creation parameters
|
||||||
|
|
||||||
|
if (hwnd)
|
||||||
|
{
|
||||||
|
ShowWindow(hwnd, iCmdShow);
|
||||||
|
UpdateWindow(hwnd);
|
||||||
|
|
||||||
|
while (GetMessage(&msg, NULL, 0, 0))
|
||||||
|
{
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (iMsg)
|
||||||
|
{
|
||||||
|
case WM_CREATE:
|
||||||
|
return 0; // return -1 to cancel the creation of the window
|
||||||
|
|
||||||
|
case WM_PAINT:
|
||||||
|
{
|
||||||
|
HDC hdc;
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
RECT rect;
|
||||||
|
|
||||||
|
hdc = BeginPaint(hwnd, &ps);
|
||||||
|
|
||||||
|
GetClientRect(hwnd, &rect);
|
||||||
|
SetBkMode(hdc, TRANSPARENT);
|
||||||
|
|
||||||
|
DrawText(hdc, L"Hello World!", -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
|
||||||
|
EndPaint(hwnd, &ps);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_CLOSE:
|
||||||
|
if (MessageBox(hwnd, L"Sure?", L"Confirm Close", MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES)
|
||||||
|
DestroyWindow(hwnd);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DefWindowProc(hwnd, iMsg, wParam, lParam);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user