Skip to content

Instantly share code, notes, and snippets.

@Ghost-VR
Forked from coffeenotfound/h.code-snippets
Last active June 5, 2024 00:20
Show Gist options
  • Save Ghost-VR/d71f07cb6a3226aec28e4dba53360a72 to your computer and use it in GitHub Desktop.
Save Ghost-VR/d71f07cb6a3226aec28e4dba53360a72 to your computer and use it in GitHub Desktop.
Visual Studio Code Snippet: C/C++ Header Guard; Auto Include
{
"Add include guard": {
"prefix": "guard",
"description": "Adds an ifndef include guard to a C/C++ header",
"body": [
"#ifndef __${TM_FILENAME/^([^\\.]*)\\..*$/${1:/upcase}/}_${TM_FILENAME/^.*\\.([^\\.]*)$/${1:/upcase}/}__",
"#define __${TM_FILENAME/^([^\\.]*)\\..*$/${1:/upcase}/}_${TM_FILENAME/^.*\\.([^\\.]*)$/${1:/upcase}/}__",
"",
"$0",
"",
"#endif // __${TM_FILENAME/^([^\\.]*)\\..*$/${1:/upcase}/}_${TM_FILENAME/^.*\\.([^\\.]*)$/${1:/upcase}/}__",
"",
]
},
"Auto include header file": {
"prefix": "includeh",
"description": "Auto include C/C++ header file",
"body": [
"#include \"${TM_FILENAME/(\\.cpp|\\.c)/.h/}\"",
"$0",
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment