diff options
| author | Hunter Kvalevog <hunter@kvog.sh> | 2025-09-11 22:19:39 -0500 |
|---|---|---|
| committer | Hunter Kvalevog <hunter@kvog.sh> | 2025-09-11 22:19:39 -0500 |
| commit | d9b9e0800ca1fd4097c03c50868801e79cab6331 (patch) | |
| tree | 422a6b9a1060048f84aa8a7a2795a962ff6041dd /content/cheatsheets | |
| parent | 4d58de2f1d9b2ed61d351bc1c5640b784b575ff7 (diff) | |
Diffstat (limited to 'content/cheatsheets')
| -rw-r--r-- | content/cheatsheets/c_cpp.md | 47 |
1 files changed, 28 insertions, 19 deletions
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 <TargetConditionals.h> - #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 <TargetConditionals.h> +#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) |