Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How deep can I #define?

Tags:

c++

emoji

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

like image 301
Karol Sobański Avatar asked Oct 10 '19 17:10

Karol Sobański


2 Answers

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() {
    🍏🍏{} == 🍊🍊{};
}
like image 27
eerorika Avatar answered Oct 04 '22 20:10

eerorika


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.

like image 100
churill Avatar answered Oct 04 '22 19:10

churill