<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112065>112065</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
When a macro contains '<' or '>', clang is unable to handle it correctly.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
xb284524239
</td>
</tr>
</table>
<pre>
When I try to pass a macro which contains `<` or `>` symbols, my code fails to compile. If I remove the `<` and `>` symbols, it compiles without issues. (BTW, OS: Windows10, IDE: VSCode)
```
// CMakeLists.txt
cmake_minimum_required(VERSION 3.30)
project(Test006 VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(Test006 main.cpp)
set(PRODUCT_AUTHOR "Paul Xu <abc123@qq.com>") # pass a macro which contains '<' or '>'
target_compile_definitions(Test006 PRIVATE PRODUCT_AUTHOR="${PRODUCT_AUTHOR}")
```
```
// main.cpp
#include <print>
int main(int argc, char *argv[]) {
std::println("The author is: {}", PRODUCT_AUTHOR);
return 0;
}
```
```
// compile_commands.json (Generated automatically by CMake)
[
{
"directory": "C:/Workspace/VSCode_Workspace/Test006/build",
"command": "C:\\PROGRA~1\\LLVM\\bin\\CLANG_~1.EXE -DPRODUCT_AUTHOR=\"\\\"Paul Xu <abc123@qq.com>\\\"\" -O0 -std=gnu++23 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -g -Xclang -gcodeview @CMakeFiles\\Test006.dir\\main.cpp.obj.modmap -o CMakeFiles\\Test006.dir\\main.cpp.obj -c C:\\Workspace\\VSCode_Workspace\\Test006\\main.cpp",
"file": "C:\\Workspace\\VSCode_Workspace\\Test006\\main.cpp",
"output": "CMakeFiles\\Test006.dir\\main.cpp.obj"
}
]
```
```
// error logs
[main] Building folder: c:/Workspace/VSCode_Workspace/Test006/build
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Workspace/VSCode_Workspace/Test006/build --config Debug --target all --
[build] [1/4 25% :: 0.021] Scanning C:/Workspace/VSCode_Workspace/Test006/main.cpp for CXX dependencies
[build] FAILED: CMakeFiles/Test006.dir/main.cpp.obj.ddi
[build] C:\Windows\system32\cmd.exe /C ""C:/Program Files/LLVM/bin/clang-scan-deps.exe" -format=p1689 -- C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -DPRODUCT_AUTHOR="\"Paul Xu <abc123@qq.com>\"" -O0 -std=gnu++23 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -g -Xclang -gcodeview -x c++ C:/Workspace/VSCode_Workspace/Test006/main.cpp -c -o CMakeFiles\Test006.dir\main.cpp.obj -resource-dir "C:/Program Files/LLVM/lib/clang/19" -MT CMakeFiles\Test006.dir\main.cpp.obj.ddi -MD -MF CMakeFiles\Test006.dir\main.cpp.obj.ddi.d > CMakeFiles\Test006.dir\main.cpp.obj.ddi.tmp && "C:/Program Files/CMake/bin/cmake.exe" -E rename CMakeFiles\Test006.dir\main.cpp.obj.ddi.tmp CMakeFiles\Test006.dir\main.cpp.obj.ddi"
[build] The system cannot find the file specified.
[build] ninja: build stopped: subcommand failed.
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Workspace/VSCode_Workspace/Test006/build --config Debug --target all -- exited with code: 1
[driver] Build completed: 00:00:00.076
[build] Build finished with exit code 1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMV1tv4jAW_jXm5ShRcAiXBx4gId1q22mX0pm-ISc24JnEzthOp7zMb1_ZJpSWUbuMVquVKhpfzvG5fZ99iNZ8KxibomSOkqxHWrOTavpS4PEgwQMcT3qFpPvptx0TcA1G7cFIaIjWQKAmpZLwa8fLHZRSGMKFBjSMUJyiYQRS-cHCDvS-LmSlEU6h3kMpKYMN4ZW26kpZN7xiIVxv4BoUq-U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