Changes

Using Objective-C Preprocessor Directives

3 bytes added, 20:33, 12 November 2009
Changing the Objective-C Language with #define
== Changing the Objective-C Language with #define ==
My first ever job involved writing communications software using the C programming language (on which Objective-C is based). I inherited some code written by a former employee who loathed the C language and preferred to use another programming language (the name of which escapes me). When I looked at his C code it looked nothing like any C code I had ever seen before in my life. After about an hour of trying to understand how this could be possible (surely the compiler should have refused to compile this) I realized the other programmer had using the #define compiler directive to "modify" the syntax of the C programming language to make it look more like his preferred language. Whilst I am not suggesting that you too go to these lengths it is worth knowing that such adaptability is provided by the #define preprocessor statement.
Lets begin with a simple example and write a definition that assigns the word ''MINUS'' to the minus sign (-):