# #define

Here is an example, here defined string `PI` and `SQUARE(x)` will be replace by compiler at compile time

```cpp
#define PI 3.14159
#define SQUARE(x) ((x) * (x))

int main() {
    double radius = 5.0;
    double area = PI * SQUARE(radius);
    // ...
}
```

Here is another example

```cpp
#define MAX(a, b) ((a) > (b) ? (a) : (b))

int main() {
    int x = 5, y = 7;
    printf("Max is: %d\n", MAX(x, y));  // Output: Max is: 7
    
    // Be careful with side effects:
    printf("Max is: %d\n", MAX(x++, y++));  // This might not behave as expected
}
```

Multiline Marcos

```cpp
#define MULTI_LINE_MACRO do { \
    printf("This is a multi-line macro.\n"); \
    printf("It can contain multiple statements.\n"); \
} while(0)

int main() {
    MULTI_LINE_MACRO;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.tejpratapsingh.com/_/cpp/code/pre-processors/define.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
