﻿# V1119\. Preprocessing directive is present within a macro argument\. This leads to undefined behavior\.

A token that looks like a preprocessing directive should not be used as a macro argument\. Using preprocessing directives as macro arguments results in undefined behavior\.

Look at the example:

```cpp
#include <stdio.h

#define PRINT(arg) printf("%s", #arg)

int main(int argc, char *argv[])
{
  PRINT(My program prints:
    #ifndef FLAG
      hello.
    #else
      world.
    #endif 
  );
}
```

Depending on whether the `FLAG` macro is defined, the developer expects the program to print either `My program prints: hello` or `My program prints: world` to `stdout`\. Because the behavior is undefined, the compiler can do anything in this situation\.

If a program is compiled using [GCC](https://godbolt.org/z/ee6z3frKo) or [Clang](https://godbolt.org/z/ee6z3frKo) without defining the `FLAG` macro, the result will be one of the expected options:

```cpp
My program prints: hello.
```

However, a program compiled using [MSVC](https://godbolt.org/z/hKsK45xva) will print an unexpected result:

```cpp
My program prints: #ifndef FLAG hello. #else world. #endif
```

The fixed code:

```cpp
#include <stdio.h>

#define PRINT(arg) printf("%s", #arg)

int main(int argc, char *argv[])
{
#ifndef FLAG
  PRINT(My program prints: hello.);
#else
  PRINT(My program prints: world.);
#endif 
}
```

Now all programs compiled using different compilers [print the same text](https://godbolt.org/z/4KEcr4xvd) depending on the `FLAG` macro definition\.