From d9b9e0800ca1fd4097c03c50868801e79cab6331 Mon Sep 17 00:00:00 2001 From: Hunter Kvalevog Date: Thu, 11 Sep 2025 22:19:39 -0500 Subject: --- .gitignore | 1 + content/cheatsheets/c_cpp.md | 47 ++++++++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index faa6c31..3d8bbdb 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store +.hugo_build.lock public \ No newline at end of file diff --git a/content/cheatsheets/c_cpp.md b/content/cheatsheets/c_cpp.md index e25e874..c1eb6ca 100644 --- a/content/cheatsheets/c_cpp.md +++ b/content/cheatsheets/c_cpp.md @@ -6,6 +6,8 @@ title = 'C/C++' * [Platform detection](#platform-detection) * [Compiler detection](#compiler-detection) * [Architecture detection](#architecture-detection) + * [GCC pragmas](#gcc-pragmas) + * [MSVC pragmas](#msvc-pragmas) * [Standard Headers](#standard-headers) ## Preprocessor Definitions @@ -19,24 +21,8 @@ title = 'C/C++' #endif #ifdef __APPLE__ - // Apple - - #include - #idef TARGET_OS_OSX - // macOS - #elif TARGET_OS_IPHONE - // Some kind of mobile device - #if TARGET_OS_MACCATALYST - // Mac Catalyst - iOS app on macOS - #elif TARGET_OS_VISION - // visionOS - #elif TARGET_OS_TV - // tvOS - #else - // iOS - #endif - #endif // TARGET_OS_OSX -#endif // __APPLE__ + // Apple - flags for specific devices defined in +#endif #ifdef __linux__ // Linux @@ -55,7 +41,7 @@ title = 'C/C++' #endif #ifdef _MSC_VER - // Visual C++ + // Visual C #endif ``` @@ -70,6 +56,29 @@ title = 'C/C++' #endif ``` +### GCC pragmas +``` +// Push/pop warning state +#pragma GCC diagnostic push +#pragma GCC diagnostic pop + +// Disable a warning +#pragma GCC diagnostic ignored "-Wunused-variable" +``` + +### MSVC pragmas +``` +// Link against abc.lib +#pragma comment(lib, "abc.lib") + +// Push/pop warning state +#pragma warning(push) +#pragma warning(pop) + +// Disable a warning +#pragma warning(disable: 4996) +``` + ## Standard Headers * [C standard headers](https://en.cppreference.com/w/c/header.html) -- cgit v1.2.3