56
u/Typewar Apr 23 '19 edited Apr 23 '19
Lol, we had a CTF task that looked something like this just a LOT bigger
5
0
97
u/Ivaalo Apr 23 '19
You can define anything in C++ ?
91
u/x32byTe Apr 23 '19
Yeah, almost everything
74
Apr 23 '19
Correct me if I'm wrong, but it's basically a find+replace for the compiler, right?
88
→ More replies (3)26
u/ProgramTheWorld Apr 23 '19
A bit more complex than that - it replaces tokens and not just your usual Ctrl-F type of find and replace.
→ More replies (3)→ More replies (2)10
u/Ivaalo Apr 23 '19
What's the purpose of defining something to replace "int" or even ";" ?
68
→ More replies (11)27
u/RussianMadMan Apr 23 '19
In case of "int", base types like this usually typedef'ed to something like int32_t for compatibility reasons. Semicolon replacement is just side effect of how preprocessor works
→ More replies (1)16
Apr 23 '19
So a bit of background.
#defineis not part of the C or C++ spec; it's part of the C preprocessor (which is a separate thing) spec. You can run the C preprocessor over virtually any code in any language, as long as you want it to have transclusion, compile-time flow control, and macros. It takes in code and outputs macro-completed code.So, technically, you can define anything in the C preprocessor and, as long as you include it in your buildchain, you can define anything in anything.
→ More replies (2)7
u/HowIsntBabbyFormed Apr 23 '19
Are all the
#terms preprocessor directives? So,#includeis not actually part of the c/c++ spec? Without the preprocessor c/c++ has no way to import other libraries?5
Apr 23 '19
Mostly correct. All the header transclusions are done in the preprocessor, as are the include guards (#ifdef...#endif and #pragma). Technically, the preprocessor itself is part of the spec - but the compiler itself calls the preprocessor; it doesn't know anything about preprocessor declarations itself, aside from some line number remapping the PP provides (for error reporting).
→ More replies (4)2
u/brisk0 Apr 23 '19 edited Apr 23 '19
The macro must be a valid identifier
It can expand to anything.
→ More replies (2)
56
4
u/Burn_Stick Apr 23 '19
int main ()
{
std::cout << "Yeet!";
return 0;
}
if i'm not mistaken (also im not sure if there is spacing between yEet and yEEt (the same thing applies for yEEt and yeEt))
→ More replies (2)1
4
3
3
3
3.7k
u/RavenCarci Apr 23 '19
Thanks, I hate it
729
u/verbosemongoose Apr 23 '19
Thanks, I yeet it
→ More replies (3)442
→ More replies (6)154
u/polenannektator Apr 23 '19
26
u/sneakpeekbot Apr 23 '19
Here's a sneak peek of /r/TIHI using the top posts of all time!
#1: Thanks, I hate lollipops now | 217 comments
#2: Thanks I Hate It | 208 comments
#3: Thanks, I hate custom face printed helmets. | 366 commentsI'm a bot, beep boop | Downvote to remove | Contact ^^me | ^^Info | ^^Opt-out
→ More replies (1)15
595
u/embrace- Apr 23 '19
Blessed #define usage
71
Apr 23 '19
The idea that you can #define language constructs is both absurdly powerful but dear god if its used wrong, the fucking mess it can cause. I don't know C well but can you do something with spaces and line breaks in define. All of the examples above had no whitespace.
105
u/Chevaboogaloo Apr 23 '19
Yeah my favorite is that you can #define true false
64
46
→ More replies (2)18
Apr 23 '19
#define struct union is the best thing to put in someone's C code if you really hate them.
→ More replies (2)0
2
2
u/TRUEequalsFALSE Apr 23 '19
Are you writing C in Eclipse?!
2
u/x32byTe Apr 23 '19
Yeah.. i don't like visual studio...
2
u/TRUEequalsFALSE Apr 23 '19
I haven't used it, but in my experience, Eclipse doesn't play nicely with anything but Java. How'd you get this to work so well?
3
u/x32byTe Apr 23 '19
i think its called "eclipse cpp" or something like that.. it works for simple programs but i haven't figured out yet how to add external libs, etc. so i don't know if it works with more advanced stuff too.
2
u/warmCabin Apr 23 '19
I saw one like this where they got a Java hello world to compile
2
u/x32byTe Apr 23 '19
w8 what?! how?! i you find this could you send it to me? because I'm pretty good in Java (or at least I think so) and i have no clue how to do this
→ More replies (1)
2
u/trexButtbutt Apr 23 '19
Why are you using eclipse for c++?
3
u/x32byTe Apr 23 '19
I don't like visual studio very much
3
376
193
u/threesixzero Apr 23 '19
what the fuck is wrong with people
93
u/e8dirqd3 Apr 23 '19
They're generously sacrificing their education for short-lived meme karma to guarantee the job security of the previous generation.
8
u/MonotonousProtocol Apr 23 '19
Short-lived? Its been 5 yrs since it came out and I still havent seen any sign of it going to fade away up until today...
291
u/NeinJuanJuan Apr 23 '19 edited Apr 23 '19
YeetScript
..is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations.
During the 2020s, YeetScript gradually gained popularity. Nowadays (in 2038), it is one of the most widely used programming languages.
120
36
u/6c696e7578 Apr 23 '19
2038
Yeah right, like the UNIX epoch won't kill us all.
→ More replies (1)19
u/YourAverageNutcase Apr 23 '19
Too bad the glitch is only on 32bit CPU’s. Then again, I’m sure there will still be plenty of old servers affected.
→ More replies (6)7
18
→ More replies (1)7
u/CaffeineSippingMan Apr 23 '19
Isn't that the same language as Yeet?
8
u/kyzfrintin Apr 23 '19 edited Apr 23 '19
Nah, it's a bootstrapped wrapper around pure Yeet that cross-compiles at a higher level.
I have no idea if I used any if those words correctly
→ More replies (2)
280
84
u/errormaker Apr 23 '19
Can I rename throw in Java to Yeet?
93
63
u/Sipkab Apr 23 '19
The closest you can get is by declaring a new exception class.
class Yeet extends RuntimeException { ... } ... throw new Yeet();Best thing is that you can catch yeets this way.
try { ... } catch (Yeet yeet) { //dab or something }Nice.
→ More replies (2)24
→ More replies (2)27
u/EagleOneGS Apr 23 '19
Oh my, I want a meme programming language now that utilizes as much modern slang/meme keywords as possible.
OwO (!yes) { yeet new FuckyWucky(); }
8
u/alt-of-deleted Apr 23 '19
Oh my God,
yeet new FuckyWucky();is something I need in my code right now6
→ More replies (1)4
16
u/word_clouds__ Apr 23 '19
Word cloud out of all the comments.
Fun bot to vizualize how conversations go on reddit. Enjoy
13
14
26
26
u/SpareTesticle Apr 23 '19 edited Apr 23 '19
I'm curious if whitespace makes a difference
If we redefined 'yEEt' as
#define yEEt :would we call the scope operator with
yEETyEET //or
yEEt yEEt //or
yEEt yEEt?
EDIT: updated the define statement from yEET to yEEt, or as the senior dev would say
git commit -m "typo"→ More replies (2)14
u/aathma Apr 23 '19
I think the :: operator counts as one term as opposed to a conjunction of two :'s so I don't think it's possible.
→ More replies (1)8
u/ARM32 Apr 23 '19
#define yEEt ::11
u/SpareTesticle Apr 23 '19
Thanks for the code review. This commenting feels eerily like working rather than slacking off on reddit.
9
6
6
u/scrubbkt Apr 23 '19
I had a professor do something similar in Java. He replaced the 'equals' method with one he wrote using only the word main. [Proof] (https://i.imgur.com/WjQE5cc.jpg)
5
4
u/the1mrx Apr 23 '19
Your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should.
4
15
7
1
6
6
u/ScaglieDiGrana Apr 23 '19 edited Apr 23 '19
#define yEeEt #define
at the top to make it better
→ More replies (1)2
3
3
5
u/_under_ Apr 23 '19
WTF. Surely you should put the opening Yeeeet in the same line.
→ More replies (1)
2
2
2
2
2
u/maxux Apr 23 '19
My code for colleague's birthday https://gist.github.com/maxux/97ff48371dbe28305f8115c829717607
2
2
2
u/TheTsar Apr 23 '19 edited Apr 23 '19
Why not define those pp directives in a separate file (yeet) and then simply #include “yeet”
Edit: Why not direct the compiler to use a custom standard library or force the compiler to link against an object file with custom symbol tables analogous to your prep directives, thus eliminating the need for the #include statement. Then there would only been yeet (and derivations thereof, e.g. yEet).
Edit 2: Why not write a custom compiler (a program called yeet) that mimics the functionality of the brainfuck programming language, except instead of alpha-numeric symbols to program address and pointer shifting, there are only derivations of the word “yeet” that provide the same functionality. Then, you compile your file (yeet.yeet) with the compiler yeet as “yeet yeet.yeet” which will then print to the standard output “yeet.” The plaintext of the program, the program’s output, and the compiler used to create the program will then all be “yeet” (or derivations thereof).
Edit 3: Why not fabricate a custom processor and simple monolithic kernel of which all symbol tables, memory addresses (virtual or otherwise; including paged space), and processor operation codes were variations on the word “yeet” where the trinary number system is used to represented the three base symbols of the system, ‘y,’ ‘e,’ and ‘t.’ Then, even if a program created within this environment appeared to use symbols or words outside of the scope of “yeet,” there could be no possible fundamental execution or un-abstracted program that did not use exclusively the word “yeet” or otherwise symbolic derivations thereof, be they trinary representations or capital variations.
2
2
u/ree___e Apr 23 '19
show this the next time you have a job interview you're guaranteed to get the job
2
u/concious_atoms Apr 23 '19
Oh fuck no , Eclipse & yeeting please god no please stop it please delete it it's hurting my eyes ....
2
2
u/Pixelmod Apr 23 '19
I'm just gonna remind y'all that if you compile with CLang, you are allowed to use emojis just about everywhere.
Therefore you could swarm your code with #define 🔵 std or #define 🤣 int and so on... then watch the worlds burn.
2
u/Orffyreus Apr 23 '19
Writing yeeT yet yeetT is optional and executed by default at the end of the Yeet function.
2
2
2
2
2
2
u/AX-11 Apr 23 '19
what have you brought upon this cursed land?
2
u/youlooklikeajerk Apr 23 '19
A just question, my liege. Late is the hour in which this conjurer chooses to appear
→ More replies (1)
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
u/redtoasti Apr 23 '19
changes all keywords, operators and expressions to variations of yeet
still doesnt use "using namespace std"
I approve
1
1
1
u/Turtle_ini Apr 23 '19
Put those definitions into a separate header file with an inconspicuous name.
1
1
u/BitPoet Apr 23 '19
Wouldn't that print "main"? Or does the C++ preprocessor skip things in quotes?
1
1
1
1.7k
u/Eznix Apr 23 '19
Try making a working program with this and ask someone else to fix your bugs.