Skip to content

Instantly share code, notes, and snippets.

@ClearlyKyle
Created December 4, 2023 11:47
Show Gist options
  • Save ClearlyKyle/2834d91a91c361db9c281a447f783bd1 to your computer and use it in GitHub Desktop.
Save ClearlyKyle/2834d91a91c361db9c281a447f783bd1 to your computer and use it in GitHub Desktop.
VSCode snippets for generating a single-header defines. "#header-single" - generates a template for the header file to be used as a single-file header, "#header-guards" generates the standard guard macros to prevent multiple inclusions of a header file
"Create a single header C file": {
"prefix": "#header-single",
"body": [
"#ifndef __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__",
"#define __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__",
"$0",
"#endif // __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__",
"",
"#ifdef ${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_IMPLEMENTATION",
"#endif // ${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_IMPLEMENTATION"
],
"description": "Generate a C header file template with proper header guards, https://github.com/nothings/stb/blob/master/docs/stb_howto.txt"
},
"Create header guards": {
"prefix": "#header-guards",
"body": [
"#ifndef __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__",
"#define __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__",
"$0",
"#endif // __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__"
],
"description": "Quickly generate header guards"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment