简体   繁体   中英

How deep can I #define?

I need to use #define and using =; as much as I can to replace possibly everything in C++ with emojis.

Is it possible to #define preprocessors like #define #define or at least #define if , #define == , etc.? 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

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.

Just as a proof of concept, the following code compiles in visual studio 2019 with platform toolset v142.

#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 . You will only need the latter.

Is it possible to #define preprocessors like #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

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.


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() {
    🍏🍏{} == 🍊🍊{};
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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