Abl-electronic PIC Microcontrollers PIC16 Bedienungsanleitung Seite 137

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 312
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 136
Here is a simple example:
// A simple macro which returns greater of its 2 arguments:
#define _MAX(A, B) ((A) > (B)) ? (A) : (B)
// Let's call it:
x = _MAX(a + b, c + d);
/* Preprocessor will transform the previous line into:
x = ((a + b) > (c + d)) ? (a + b) : (c + d) */
It is highly recommended to put parentheses around each of the arguments in
macro body – this will avoid possible problems with operator precedence.
Undefining Macros
You can undefine a macro using the #undef directive.
#undef
macro_identifier
Directive #undef detaches any previous token sequence from the
macro_iden-
tifier
; the macro definition has been forgotten, and the
macro_identifier
is
undefined. No macro expansion occurs within
#undef lines.
The state of being defined or undefined is an important property of an identifier,
regardless of the actual definition. The
#ifdef and #ifndef conditional direc-
tives, used to test whether any identifier is currently defined or not, offer a flexible
mechanism for controlling many aspects of a compilation.
After a macro identifier has been undefined, it can be redefined with
#define,
using the same or a different token sequence.
MikroElektronika:
Development
tools
-
Books
-
Compilers
129
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Seitenansicht 136
1 2 ... 132 133 134 135 136 137 138 139 140 141 142 ... 311 312

Kommentare zu diesen Handbüchern

Keine Kommentare