# #ifdef

If we include a header file 2 times (maybe in multiple files), we will get error saying multiple declaration found.

To overcome this, we need to ignore multiple inclusion, we define a [macro](/_/cpp/code/pre-processors/define.md). which we check if `ifdef` and ignore inclusion if already incuded.

Here is an example:

```cpp
#define DEBUG

#ifdef DEBUG
    std::cout << "Debug mode is on" << std::endl;
#endif

#ifndef NDEBUG
    // Code for debug builds
#else
    // Code for release builds
#endif
```

Or another example, we check system config, if system is `unix` we use `cls` and if it us `linux` we use `clear` and many more.

```cpp
#ifdef _WIN32
    #define CLEAR_SCREEN "cls"
#else
    #define CLEAR_SCREEN "clear"
#endif

#if defined(__cplusplus) && __cplusplus >= 201703L
    // Use C++17 features
#elif defined(__cplusplus) && __cplusplus >= 201402L
    // Use C++14 features
#else
    #error "This program requires at least C++14"
#endif
```


---

# 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/ifdef.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.
