{"id":20112941,"url":"https://github.com/yottaawesome/cross-platform-cpp-playground","last_synced_at":"2026-02-10T04:31:27.752Z","repository":{"id":209222283,"uuid":"723509149","full_name":"yottaawesome/cross-platform-cpp-playground","owner":"yottaawesome","description":"Various dumb experiments with cross-building C++ projects on MSVC, GCC and Clang for Windows and Linux.","archived":false,"fork":false,"pushed_at":"2024-10-23T09:40:39.000Z","size":98,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-19T20:01:42.140Z","etag":null,"topics":["clang","cpp","cpp-modules","cpp20","gcc","linux","msvc","visual-studio","windows"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yottaawesome.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-25T22:18:52.000Z","updated_at":"2025-01-01T15:38:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"2af392e6-3807-4b91-b834-e43229dccc55","html_url":"https://github.com/yottaawesome/cross-platform-cpp-playground","commit_stats":null,"previous_names":["yottaawesome/cross-platform-cpp-playground"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yottaawesome%2Fcross-platform-cpp-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yottaawesome%2Fcross-platform-cpp-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yottaawesome%2Fcross-platform-cpp-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yottaawesome%2Fcross-platform-cpp-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yottaawesome","download_url":"https://codeload.github.com/yottaawesome/cross-platform-cpp-playground/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241557116,"owners_count":19981877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clang","cpp","cpp-modules","cpp20","gcc","linux","msvc","visual-studio","windows"],"created_at":"2024-11-13T18:23:00.414Z","updated_at":"2026-02-10T04:31:22.731Z","avatar_url":"https://github.com/yottaawesome.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cross-platform C++ playground\r\n\r\n## Introduction\r\n\r\nThis repo is for experimenting with building cross-platform C++ in Visual Studio (with an emphasis on module-based code) across Windows and Linux and across the big three C++ compilers: MSVC, GCC and Clang. It also functions as a useful testing ground for evaluating support of various different C++ features across the big three compilers. This repo was originally borne out of some experiments I did in my cpp-playground repo, before I realised this isn't just any other random experiment, but something worthwhile pursuing in a separate repo.\r\n\r\nI intend to add CMake into the mix at some point, just to make things even more complicated.\r\n\r\n## Cross-compiling and building C++ with Visual Studio\r\n\r\n### Set up\r\n\r\nThis repo assumes you work on a Windows machine with WSL2 and that Visual Studio 2022 is your primary IDE. You'll need the _Desktop development with C++_ and the _Linux and embedded development with C++_ workloads. Building for Clang requires the _C++ Clang Compiler for Windows_ and _MSBuild Support for LLVM (clang-cl) toolset_ optional components.\r\n\r\n### Building for Clang\r\n\r\nVisual Studio's Clang support requires installing the Clang components -- [follow this for more info](https://learn.microsoft.com/en-us/cpp/build/clang-support-msbuild?view=msvc-170).\r\n\r\n### Building for Linux\r\n\r\n* You need a WSL2 distro running on your machine. I use Ubuntu. You can list your WSL2 instances with `wsl --list -v`.\r\n* Install the required tools for Visual Studio on your WSL2 VM: `sudo apt install -y openssh-server build-essential gdb rsync make zip`\r\n* [Enable SSH on the VM](https://jmmv.dev/2022/02/wsl-ssh-access.html). Test locally with `ssh -p 22 \u003cusername\u003e@localhost`.\r\n* Configure Visual Studio  to connect to the VM: `TOOLS \u003e Options \u003e Cross Platform \u003e Connection Manager`.\r\n* [Install additional GCC/g++ versions if necessary](https://phoenixnap.com/kb/install-gcc-ubuntu) (I use GCC-13/g++-13). Update the C++ Compiler option to point to the preferred compiler (and don't forget to change the language standard and enable additional flags like `-fmodules-ts` as appropriate for your compiler).\r\n* You should be able to open the solution and build any one of the projects. If building for Linux, your WSL2 distro _needs_ to be running (you can log into it with `wsl ~` assuming you've set it as your default).\r\n\r\n## Notes\r\n\r\nGCC's and Clang's support for C++20 modules is still a bit flaky and lags behind MSVC's support. In GCC-13, `#including \u003cchrono\u003e` appears to cause an ICE and GCC also appears to dislike it when a module implementation unit (e.g. `somemodule.cpp`) has the same name as its module interface unit (e.g. `somemodule.ixx`). I wasn't able to get modules behaving in Visual Studio with Clang, but I could build them by dropping to the `x64 Native Tools Command Prompt for VS 2022` tool and following Rainer Grimm's instructions (linked below). One thing to note with Clang's implementation is the `.cppm` extension that gets compiled into a `.pcm` file.\r\n\r\n## Additional resources\r\n\r\n* [C++20: Module Support of the Big Three](https://www.modernescpp.com/index.php/c20-module-support-of-the-big-three-compilers/)\r\n* [C++20: More Details about Module Support of the Big Three](https://www.modernescpp.com/index.php/c20-more-details-about-module-support-of-the-big-three/)\r\n* [Clang/LLVM support in Visual Studio projects](https://learn.microsoft.com/en-us/cpp/build/clang-support-msbuild?view=msvc-170)\r\n* [Walkthrough: Build and debug C++ with WSL 2 and Visual Studio 2022](https://learn.microsoft.com/en-us/cpp/build/walkthrough-build-debug-wsl2?view=msvc-170)\r\n* [Tutorial: Create C++ cross-platform projects in Visual Studio](https://learn.microsoft.com/en-us/cpp/build/get-started-linux-cmake?view=msvc-170)\r\n* [C++ Compiler Support](https://en.cppreference.com/w/cpp/compiler_support): useful to ensure features used in your cross-platform code align with your available compilers.\r\n* [C++ Standards Support in GCC](https://gcc.gnu.org/projects/cxx-status.html)\r\n* [C++ Support in Clang](https://clang.llvm.org/cxx_status.html)\r\n* [Microsoft C/C++ language conformance by Visual Studio version](https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=msvc-170)\r\n* [CMake's cxxmodules](https://cmake.org/cmake/help/latest/manual/cmake-cxxmodules.7.html)\r\n* [Clang Standard C++ Modules](https://clang.llvm.org/docs/StandardCPlusPlusModules.html)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyottaawesome%2Fcross-platform-cpp-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyottaawesome%2Fcross-platform-cpp-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyottaawesome%2Fcross-platform-cpp-playground/lists"}