summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--c.html.markdown10
1 files changed, 8 insertions, 2 deletions
diff --git a/c.html.markdown b/c.html.markdown
index 1ad0dd53..c47a2df7 100644
--- a/c.html.markdown
+++ b/c.html.markdown
@@ -756,8 +756,14 @@ as the C file.
/* Like c source files macros can be defined in headers and used in files */
/* that include this header file. */
#define EXAMPLE_NAME "Dennis Ritchie"
-/* Function macros can also be defined. */
-#define ADD(a, b) (a + b)
+
+/* Function macros can also be defined. */
+#define ADD(a, b) ((a) + (b))
+
+/* Notice the parenthesis surrounding the arguments -- this is important to */
+/* ensure that a and b don't get expanded in an unexpected way (e.g. consider */
+/* MUL(x, y) (x * y); MUL(1 + 2, 3) would expand to (1 + 2 * 3), yielding an */
+/* incorrect result) */
/* Structs and typedefs can be used for consistency between files. */
typedef struct Node