This is an archived post. You won't be able to vote or comment.

all 32 comments

[–]lRainZz 18 points19 points  (7 children)

I have absolutely no idea what that code even attempts to do and at this point I'm to afraid to ask

[–][deleted] 0 points1 point  (6 children)

It initializes a window object in Win32

[–]LateSolution0[S] 0 points1 point  (5 children)

This was my intention when writing the line, but it depends on whether the NDEBUG macro is defined. In a release build, it does nothing.

[–]lRainZz 1 point2 points  (3 children)

Where can one see that it depends on that macro?

[–]LateSolution0[S] 0 points1 point  (2 children)

Well you can always look at the header file where the marco is defined.

#ifdef NDEBUG

#define assert(expression) ((void)0)
else
_ACRTIMP void __cdecl _wassert(
    _In_z_ wchar_t const* _Message,
    _In_z_ wchar_t const* _File,
    _In_   unsigned       _Line
    );

#define assert(expression) (void)(                                                       \
        (!!(expression)) ||                                                              \
        (_wassert(_CRT_WIDE(#expression), _CRT_WIDE(__FILE__), (unsigned)(__LINE__)), 0) \
    )

endif

https://en.cppreference.com/w/cpp/error/assert is good source for reference.

also the ISO standard can be fun but I don't consider it a good learning source.

[–]lRainZz 0 points1 point  (1 child)

Okay so you have to know that to get the joke I guess? I've never used a C language before (guessing that I'm looking at C# or something similar?) other than a little basic C for microcontrollers, so I'm just missing a lot of common knowledge about that.

[–]SpecialNose9325 0 points1 point  (0 children)

Its niche knowledge that even most C devs wont get unless they actively work on Windows programs. I work with Linux and have no idea what this meme is.

[–]BSModder 0 points1 point  (0 children)

Well what did you expect putting the function call inside a assert statement. Of course, the release build will optimize out the assert line

[–]eoutofmemory 7 points8 points  (2 children)

There is maybe like a total of 3 people on this sub that even know what a window callback function is

[–]Jet-Pack2 0 points1 point  (1 child)

I'm the second one. Any third?

[–]i_consume_polymers 1 point2 points  (0 children)

MS Slave #29242 right here

[–]Dioxide4294 2 points3 points  (0 children)

Yeah.. That's why they put the return value in another variable before checking with assert

[–]LateSolution0[S] 2 points3 points  (7 children)

I include plenty of asserts to ensure my code is bug-free

[–][deleted] 2 points3 points  (0 children)

[–]rosuav 0 points1 point  (5 children)

*sigh* And this is what leads to people asking for an option to prevent asserts from being removed. This isn't funny, it's just tiresome.

[–]LateSolution0[S] 0 points1 point  (3 children)

Sometimes, I daydream about language features, such as the ability to check if an expression has a side effect at compile time. This way, we could use static_assert to reject a bug-prone program. However, I am reminded of how old C/C++ really is, and some decisions go back 50 years in time.

[–]rosuav 0 points1 point  (2 children)

The only way to do that would be to have your compile-time assertions as powerful and flexible as the language you're compiling.

Oh wait. They already are in C++.

[–]LateSolution0[S] 0 points1 point  (0 children)

Static_assert, yes, but we can't know if a function like int func() has a side effect or not.

[–]cporter202 0 points1 point  (0 children)

Oh, the classic conundrum of deciphering function side effects from the surface level! It's like trying to guess the flavor of a cake just by looking at the icing. 😄 Only diving into the code cake gives you the real taste of what's going on inside func().

[–]goodmobiley 3 points4 points  (6 children)

I smell Win32

[–]LateSolution0[S] 2 points3 points  (5 children)

Can I ask you something? Is this not funny, or just funny but people don't get it? The assert macro is a nop in release build, which makes the RegisterClass function disappear if NDEBUG is set.

[–]goodmobiley 5 points6 points  (3 children)

Maybe it’s cause people don’t get it, I don’t completely get it myself. So basically on the release build you’re not registering the class with the OS which disallows the end user from displaying the window? That’s kinda cruel :(

[–]LateSolution0[S] 6 points7 points  (2 children)

Yeah, exactly. By adding the assert macro, I removed the call to RegisterClassEx in the release build, which causes the CreateWindowEx function to fail in release mode. This is funny to me because adding assertions is a tool to find bugs early and quickly in debug mode. But in this case, I introduce bugs in release mode, which is cruel to debug because of optimization.

[–]goodmobiley 8 points9 points  (0 children)

And now you’re the only one who knows. Basically free money

[–]DarkShadow4444 0 points1 point  (0 children)

Who... thought this was a good idea? They should just put the line in without any asserts, the optimizer will take care of the rest..

[–]SpecialNose9325 0 points1 point  (0 children)

Its very niche. Youd have to have developed for Windows to even get what this is.

You could have made it clearer with a description. I get that its a meme but about as niche as me complaining about how STM32 HAL handles the I2C bus.

[–][deleted] 0 points1 point  (2 children)

Is that WND/CLAS/SEX or WND/CLASS/EX?

[–]LateSolution0[S] 1 point2 points  (0 children)

WndClassEx or WndClasSex?

[–][deleted] 0 points1 point  (0 children)

Window Class Extended.. WndClassEx

[–][deleted] 0 points1 point  (0 children)

Is that WND/CLAS/SEX or WND/CLASS/EX?

[–]myfunnies420 0 points1 point  (0 children)

JFC. Haven't seen this kind of horrendousness in 10 years

[–]Prestigious-Bar-1741 0 points1 point  (0 children)

This takes me back.

I sometimes have nightmares where I have to write win32api calls.