Eiskomet opened a new pull request, #3078:
URL: https://github.com/apache/fory/pull/3078

   <!--
   **Thanks for contributing to Apache Fory™.**
   
   **If this is your first time opening a PR on fory, you can refer to 
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).**
   
   Contribution Checklist
   
       - The **Apache Fory™** community has requirements on the naming of pr 
titles. You can also find instructions in 
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).
   
       - Apache Fory™ has a strong focus on performance. If the PR you submit 
will have an impact on performance, please benchmark it first and provide the 
benchmark result here.
   -->
   
   ## Why?
   <!-- Describe the purpose of this PR. -->
   cpp文档中提供的cmake代码在MSVC编译环境下,编译基本示例会出现编译错误。该PR修改了给出的cmake代码对MSVC环境做出兼容。
   ## What does this PR do?
   <!-- Describe the details of this PR. -->
   
   
cpp代码的FORY_STRUCT宏使用了__VA_ARGS__宏命令,并且将__VA_ARGS__作为另一个宏函数的参数传递。这在标准是合法的,但是MSVC的旧版本预处理器的行为并不符合标准,行为和GCC、Clang不一致从而导致编译错误。而MSVC默认使用的预处理器又是旧版本的。
   
   具体为可见 [MSVC 
新预处理器概述](https://learn.microsoft.com/zh-cn/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-170)
 其中的“宏参数已“解压缩””
   
   微软官方提供 /Zc:preprocessor 和/experimental:preprocessor 
的编译选项来启用“新预处理器”也就是“标准符合性预处理器”,其中
   /Zc:preprocessor  是Visual Studio 2019 版本 16.5 
开始提供,/experimental:preprocessor 是Visual Studio 2017 版本 15.8 开始提供的实验版本。
   
   这里我给cmake的样例加上了
   ```
   if(MSVC)
       add_compile_options(/Zc:preprocessor)
   endif()
   ```
   从而让MSVC下的代码正常工作。
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to