Difference between revisions of "Hacking:Code Snippets/Miscellaneous"

From GIMP Developer Wiki
Jump to: navigation, search
(add 'Determining modifiers of keyboard events (Ctrl, Alt, etc.)')
(add TOC)
 
Line 1: Line 1:
 +
__TOC__
 +
 
=Determining compiler=
 
=Determining compiler=
  

Latest revision as of 18:26, 12 April 2014

Determining compiler

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

#ifdef __GNUC__
...
#endif

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)

}