TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The C++ preprocessor doesn’t understand anything about C++, including templates

30 点作者 cow9大约 5 年前

5 条评论

Wowfunhappy大约 5 年前
&gt; The C and C++ preprocessors are like the Windows command prompt batch language: They implement a very simple language that people still use for some reason.<p>I can tell you exactly why I use batch scripts—they&#x27;re the only type of script that will run on double click in a stock Windows install.<p>Powershell scripts won&#x27;t by default for security reasons, but for some reason for batch it&#x27;s okay. So I use batch.
评论 #23131242 未加载
Robadob大约 5 年前
We&#x27;ve come across this problem. The major testing frameworks seem to rely heavily on macros for tests. In particular, we were struggling to handle tests of thrown exceptions, as we couldn&#x27;t trivially capture the result in a variable and place that inside the macro instead. The most versatile solution we found was to use a function pointer, so that the templating wasn&#x27;t required when the function was called.
评论 #23123695 未加载
adrianN大约 5 年前
The preprocessor is a really horrible hack of a macro system. I wish we could get rid of it and replace it with something sensible, but I doubt that will ever happen.
评论 #23123649 未加载
评论 #23122962 未加载
评论 #23125088 未加载
评论 #23123003 未加载
评论 #23123120 未加载
mehrdadn大约 5 年前
Just a PSA, but if the parenthesis solution doesn&#x27;t work for you, you can define a COMMA macro and use it there (while everyone yells at you).
PunksATawnyFill大约 5 年前
Macros are inscrutable garbage and a sorry hack.