简体   繁体   English

我可以#define 多深?

[英]How deep can I #define?

I need to use #define and using =;我需要使用#defineusing =; as much as I can to replace possibly everything in C++ with emojis.尽可能用表情符号替换 C++ 中的所有内容。

Is it possible to #define preprocessors like #define #define or at least #define if , #define == , etc.?是否可以像#define #define或至少#define if#define ==等 #define 预处理器? Maybe with 'using'?也许与“使用”?

I'd like to replace operators, core language instructions... Is it possible anyhow?我想替换运算符,核心语言指令......无论如何有可能吗?

I know the aboves doesn't work, but maybe there is a way?... Please help me make something funny: :D我知道上述方法不起作用,但也许有办法?...请帮我做一些有趣的事情::D

Yes, you can.是的你可以。 You may need to think about the syntax.您可能需要考虑语法。 Easiest would be to use one emoji per keyword.最简单的方法是每个关键字使用一个表情符号。 However you may still need to write function- and variable names in clear text.但是,您可能仍需要以明文形式编写函数和变量名称。

As per Romens comment I tried it and you can also replace method names with emojis.根据 Romens 的评论,我试过了,你也可以用表情符号替换方法名称。

Just as a proof of concept, the following code compiles in visual studio 2019 with platform toolset v142.作为概念证明,以下代码使用平台工具集 v142 在 Visual Studio 2019 中编译。

#include <iostream>

#define 😎 int

😎 🍉() {
    std::cout << "I'm 🍉!";

    return 1;
}

😎 main() {
    🍉();
}

Or even more to include some of the comments:甚至更多包括一些评论:

#include <iostream>

#define 🙈 using
#define 🤷🏻‍ cout
#define 😎 int
namespace 🍏 = std;
🙈 🍏::🤷🏻‍;

😎 🍉() {
    🤷🏻‍ << "I'm";
    🍏::cout << "🍉!";

    return 1;
}

😎 main() {
    🍉();
}

Also using is something else than #define .using #define以外的其他内容。 You will only need the latter.您只需要后者。

Is it possible to #define preprocessors like #define #define是否可以像 #define #define 这样的 #define 预处理器

No, it is not possible to define macros to replace preprocessor directives.不,不可能定义宏来替换预处理器指令。 (Also, macros cannot expand into directives either). (此外,宏也不能扩展为指令)。

or at least #define if或至少#define if

This is potentially possible.这是可能的。 It depends on the compiler what input character encoding it supports.这取决于编译器它支持什么输入字符编码。 Emojis are not listed in the basic source character set specified by the language standard, so they might not exist in the character encoding used by the compiler.表情符号未列在语言标准指定的基本源字符集中,因此它们可能不存在于编译器使用的字符编码中。

Maybe with 'using'?也许与“使用”?

Emojis are equally allowed for using as they are for macros.表情符号同样可以using宏。


Note that any identifier could be an emoji (assuming they are supported in the first place) including functions, types and variables.请注意,任何标识符都可以是表情符号(假设它们首先受支持),包括函数、类型和变量。 Example:例子:

struct 🍏🍏 {};
struct 🍊🍊 {};

int main() {
    🍏🍏{} == 🍊🍊{};
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM