Skip to content

Instantly share code, notes, and snippets.

@TurtleP
Last active August 5, 2024 16:17
Show Gist options
  • Save TurtleP/533f187808f825d2ed252c42ab5926e0 to your computer and use it in GitHub Desktop.
Save TurtleP/533f187808f825d2ed252c42ab5926e0 to your computer and use it in GitHub Desktop.
Visual Studio Code: Nintendo Homebrew C/C++ Config

Configurations for Nintendo Homebrew Compilation

Warning Committing the .vscode files to your git repo should not be done, as configurations are not fully portable.

The file c_cpp_properties.json contains configurations for Nintendo 3DS, Switch, and Wii U. This helps with intellisense. Create .vscode/c_cpp_properties.json in your project directory and then copy and paste the content as applicable.

This file was changed since it was uploaded to my GitHub repository to use the "env" JSON key. This is so more profiles can be easily created with defaults for each console and then adding extras, such as a debugging profile. On top of that, it was moved to a gist because they are much easier to update.

C++ Extension

You will need to install the C/C++ Extension from Microsoft.

Further instructions about creating your own configuration files can be found on the official Visual Studio website.

Windows Users:

Instead of using {env:DEVKITPRO} as the prepended path information:

  • If you used the graphical installer, this should point to C:/devkitpro
  • If you have an existing msys2 install, this should point to C:/msys64/opt/devkitpro

Do not add this path to the environment variables. An example for the 3DS include paths:

"ctrIncludePaths": [
  "C:/msys64/opt/devkitpro/libctru/include/**",
  "C:/msys64/opt/devkitpro/portlibs/3ds/include/**"
],

If you want msys2 to be your default terminal, you will need to add its profile in the User Settings json file. Insert a new JSON key for msys2 in terminal.integrated.profiles.windows. If that JSON key does not exist, add it.

"terminal.integrated.profiles.windows": {
  "msys2": {
    "path": "C:/msys64/usr/bin/bash.exe",
    "args": ["--login", "-i"],
    "env": {
      "CHERE_INVOKING": "1",
      "MSYSTEM": "MINGW64",
      "MSYS2_PATH_TYPE": "inherit"
    }
}

Once the Terminal profile has been added, you can run the command palette, CTRL+SHIFT+P, type "Select Default" and you should see Terminal: Select Default Profile. Press Enter, highlight msys2, and again confirm your selection with Enter

{
"env": {
"defaultIncludePath": [
"${workspaceFolder}/include/**"
],
"defaultDefines": [],
/* 3DS paths and info */
"ctrIncludePaths": [
"${env:DEVKITPRO}/libctru/include/**",
"${env:DEVKITPRO}/portlibs/3ds/include/**"
],
"ctrDefines": ["__3DS__"],
"ctrCompilerPath": "${env:DEVKITPRO}/devkitARM/bin/arm-none-eabi-gcc",
/* Switch paths and info */
"hacIncludePaths": [
"${env:DEVKITPRO}/libnx/include/**",
"${env:DEVKITPRO}/portlibs/switch/include/**"
],
"hacDefines": ["__SWITCH__", "__BSD_VISIBLE"],
"hacCompilerPath": "${env:DEVKITPRO}/devkitA64/bin/aarch64-none-elf-g++",
/* Wii/Gamecube paths and info */
"rvlIncludePaths": [
"${env:DEVKITPRO}/portlibs/ppc/include/**",
"${env:DEVKITPRO}/portlibs/wii/include/**",
"${env:DEVKITPRO}/libogc/include/**",
],
"rvlDefines": ["HW_RVL"],
"dolIncludePaths": [
"${env:DEVKITPRO}/portlibs/ppc/include/**",
"${env:DEVKITPRO}/portlibs/gamecube/include/**",
"${env:DEVKITPRO}/libogc/include/**",
],
"dolDefines": ["HW_DOL"],
/* Wii U paths and info */
"cafeIncludePaths": [
"${env:DEVKITPRO}/portlibs/ppc/include/**",
"${env:DEVKITPRO}/portlibs/wiiu/include/**",
"${env:DEVKITPRO}/wut/include/**",
"${env:DEVKITPRO}/wut/usr/include/**"
],
"cafeDefines": ["__WIIU__"],
"ppcCompilerPath": "${env:DEVKITPRO}/devkitPPC/bin/powerpc-eabi-g++"
},
"configurations": [
{
"name": "3DS",
"includePath": ["${env:defaultIncludePath}", "${env:ctrIncludePaths}"],
"defines": ["${env:defaultDefines}", "${env:ctrDefines}"],
"compilerPath": "${env:ctrCompilerPath}",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-arm"
},
{
"name": "Switch",
"includePath": ["${env:defaultIncludePath}", "${env:hacIncludePaths}"],
"defines": ["${env:defaultDefines}", "${env:hacDefines}"],
"compilerPath": "${env:hacCompilerPath}",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-arm64"
},
{
"name": "Gamecube",
"includePath": ["${env:defaultIncludePath}", "${env:dolIncludePaths}"],
"defines": ["${env:defaultDefines}", "${env:dolDefines}"],
"compilerPath": "${env:ppcCompilerPath}",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-arm"
},
{
"name": "Wii",
"includePath": ["${env:defaultIncludePath}", "${env:rvlIncludePaths}"],
"defines": ["${env:defaultDefines}", "${env:rvlDefines}"],
"compilerPath": "${env:ppcCompilerPath}",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-arm"
},
{
"name": "Wii U",
"includePath": ["${env:defaultIncludePath}", "${env:cafeIncludePaths}"],
"defines": ["${env:defaultDefines}", "${env:cafeDefines}"],
"compilerPath": "${env:ppcCompilerPath}",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-arm"
}
],
"version": 4
}
@RubberDuckShobe
Copy link

Great config, but the file needs to be called c_cpp_properties.json and not c_cpp_configuration.json

@TurtleP
Copy link
Author

TurtleP commented Jun 29, 2024

Thanks, updated the README.

@gd-harco
Copy link

gd-harco commented Jul 6, 2024

I just started to try to get into wii u homebrew dev, you just saved me a lot of trial and error I thank you so much for that !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment