This wiki is out of date, use the continuation of this wiki instead

Precompiler define

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 13:38, 30 December 2007 (edit)
Sandman (Talk | contribs)
(New page: category:precompiler == Definition == '''#define''' <what to define> [<what it will be>] Defines ''what to define'' as ''what it will be''. This means that after this line, all ''wha...)
← Previous diff
Revision as of 13:39, 30 December 2007 (edit) (undo)
Sandman (Talk | contribs)
m
Next diff →
Line 32: Line 32:
</pre> </pre>
The value ''2'' on itself means very little, but ''NET_STATUS_ESTABLISHED'' immediately makes it clear what it means. The value ''2'' on itself means very little, but ''NET_STATUS_ESTABLISHED'' immediately makes it clear what it means.
 +
 +{{Precompiler_statements}}

Revision as of 13:39, 30 December 2007


Definition

#define <what to define> [<what it will be>]

Defines what to define as what it will be. This means that after this line, all what to defines will be "replaced" by what it will be.

Example

In the following example, we'll show it is possible to define words as "being" basic statements.

#define StartThisShow Program
#define GimmeSomeShit Process

StartThisShow example;
Begin
    proc();
End

GimmeSomeShit proc()
Begin
End

Used in example: Program, Process, Begin, End

Error codes are handy as well, like used in Network.DLL and LCD.DLL:

#define NET_ERROR_INVALIDADDRESS -12

This will enable the use of NET_ERROR_INVALIDADDRESS as it it were the value -12. This makes it much more clear for the programmer what the errors are. Consider this:

#define NET_STATUS_ESTABLISHED 2

The value 2 on itself means very little, but NET_STATUS_ESTABLISHED immediately makes it clear what it means.


Precompiler statements
#define#ifdef#ifndef#endif#else#if
Personal tools