Hacking:Code Snippets/Miscellaneous

From GIMP Developer Wiki
Revision as of 18:26, 12 April 2014 by Scl (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Determining compiler

To make use of GCC specific features, use the __GNUC__ macro:

#ifdef __GNUC__

You can also grep the code for __GNU to find out existing samples to learn from.

To make use of LLVM/Clang specific features, use the Clang language extensions.

See also:

Common predefined macros in GCC

Pre-defined Compiler Macros page at Sourceforge.net

Determining modifiers of keyboard events (Ctrl, Alt, etc.)

#include <gdk/gdkkeysyms.h>

my_key_event_handler(const GdkEventKey *keyevent)

/* check for Ctrl (also on OS X; do not confuse with Cmd there!): */
if (keyevent->state & GDK_CONTROL_MASK)

/* check for Alt: */
if (keyevent->state & GDK_MOD1_MASK)