Skip to content

Instantly share code, notes, and snippets.

@abiiranathan
Created April 6, 2025 18:31
Show Gist options
  • Save abiiranathan/c491c17a4e56505efc828fbb44feb3ed to your computer and use it in GitHub Desktop.
Save abiiranathan/c491c17a4e56505efc828fbb44feb3ed to your computer and use it in GitHub Desktop.
C header guard vscode snippet
{
"C++ Header Guard with extern C": {
"prefix": "guard",
"body": [
"#ifndef ${1:${TM_FILENAME_BASE/(.*)/${1:/upcase}_H/}}",
"#define ${1:${TM_FILENAME_BASE/(.*)/${1:/upcase}_H/}}",
"",
"#ifdef __cplusplus",
"extern \"C\" {",
"#endif",
"",
"$0",
"",
"#ifdef __cplusplus",
"}",
"#endif",
"",
"#endif // ${1}",
"\n"
],
"description": "Add C++ header guard with extern C protection against name mangling"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment