Slide 1

Slide 1 text

$ whoami Oliver Jones Senior Developer @ Itty Bitty Apps http:/ /iamorj.com @orj on Twitter (and Xbox, Steam, etc)

Slide 2

Slide 2 text

Metaprogramming with X Macros Or: How I learned to stop worrying and love the preprocessor.

Slide 3

Slide 3 text

What is the preprocessor?

Slide 4

Slide 4 text

What is the preprocessor? Part of C99 & C++ standards ObjC adds #import

Slide 5

Slide 5 text

What is the preprocessor? Part of C99 & C++ standards ObjC adds #import Was separate process, clang has one built in

Slide 6

Slide 6 text

What is the preprocessor? Part of C99 & C++ standards ObjC adds #import Was separate process, clang has one built in Macro language

Slide 7

Slide 7 text

What is the preprocessor? Part of C99 & C++ standards ObjC adds #import Was separate process, clang has one built in Macro language Turing complete

Slide 8

Slide 8 text

Turing what? In computability theory, a system of data-manipulation rules (such as a computer's instruction set, a programming language, or a cellular automaton) is said to be Turing complete or computationally universal if it can be used to simulate any single-taped Turing machine.

Slide 9

Slide 9 text

#import

Slide 10

Slide 10 text

#undef CRAZY For heavy wizardry and pre-processor meta-programming... The Boost C++ Library (www.boost.org)

Slide 11

Slide 11 text

all the # you need to know 2 flavours of macro object-like macros function-like macros

Slide 12

Slide 12 text

# and ## # or the “stringify” operator. turns into

Slide 13

Slide 13 text

# and ## ## or the “symbol concatenation” operator. turns into

Slide 14

Slide 14 text

What is an X Macro? At its core this: Some times this:

Slide 15

Slide 15 text

#define EVIL(plot)

Slide 16

Slide 16 text

To Xcode

Slide 17

Slide 17 text

Links Boost C++ Preprocessor Library http:/ /www.boost.org/doc/libs/1_53_0/libs/preprocessor/doc/ Boost Book (Preprocessor Chapter) http:/ /www.boostpro.com/mplbook/preprocessor.html Stack Overflow on X Macros: http:/ /bit.ly/15ZXZpt Dr Dobbs Journal http:/ /www.drdobbs.com/cpp/the-x-macro/228700289