Jump to content

  • Log In with Google      Sign In   
  • Create Account

Best comment ever

  • You cannot reply to this topic
101 replies to this topic

#81   Members   

580
Like
4Likes
Like

Posted 25 November 2015 - 09:03 AM

I just found that little gem in a collaborative hobby project.

 

/**
@brief Enables easy access to bytes in a struct for array/struct conversion.
@details stype should be trivially_copyable. Its your duty to make sure it is. Otherwise you might be in
undefined-behavior-land, which is - trust me on that - not a amusement park.
@tparam stype The type to be wrapped.
*/
template<typename stype>
union Bytes
{
stype data;
unsigned char bytes[sizeof(stype)];
};

I dont know if that is good style (its in a "details" namespace) but its quite convenient to have something like that.



#82   Members   

33494
Like
4Likes
Like

Posted 26 November 2015 - 12:27 AM

I dont know if that is good style (its in a "details" namespace) but its quite convenient to have something like that.


I can't comment on the validity of that (despite doing similar aliasing in other places smile.png), but I can suggest that the struct itself test for std::is_trivially_copyable via a std::static_assert.

template<typename stype>
union Bytes
{
	static_assert(std::is_trivially_copyable<stype>::value, "'Bytes' requires trivially-copyable types");
    
	stype data;
	unsigned char bytes[sizeof(stype)];
};

I can however confirm, with an acceptable margin of error, that your warning comment is amusing. tongue.png


It's perfectly fine to abbreviate my username to 'Servant' or 'SotL' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal | [Fly with me on Twitter]

#83   Members   

580
Like
2Likes
Like

Posted 27 November 2015 - 01:06 PM


I can't comment on the validity of that (despite doing similar aliasing in other places ), but I can suggest that the struct itself test for std::is_trivially_copyable via a std::static_assert.
template
union Bytes
{
static_assert(std::is_trivially_copyable::value, "'Bytes' requires trivially-copyable types");

stype data;
unsigned char bytes[sizeof(stype)];
};

 

Hu. I didnt know you could do a static assert inside a union/struct etc. :| Neat, i always love it when i learn something new. :) Now i only wish i could change the compiler warning regarding non-trivially_copyable types. Saying e.g. the destructor is deleted is unfortunately uninformative if you dont know unions.

 

Back to topic: Too bad. I will have to remove the comment now. :P



#84   Members   

172
Like
3Likes
Like

Posted 18 January 2016 - 11:13 PM

Not exactly a single comment but whatever.

 

As I was delving into the code of my friends who were working on a racing game, i got quite the surprise in finding a mexican buffet.

 

While working on the UI, one of them had added a tacometer to the HUD and so had needed a variable for it (tacometerDisplay). My other friends, knowing nothing about cars, had taken it wrong and called the rest of the elements of the HUD stuff like quesadillasDisplay, chiliConCarneDisplay, etc. And for each next elements, the comments devolved from making sense to stuff like "//I'm starting to lack ideas for name" or "//You can still use salsaDisplay for the next one ;)"

 

As for mines, if you ever delve into some of my WIP, you might find some //LOREM, //IPSUM, //DOLORES, etc. where I broke off and went one layer deeper/away to create something required before returning.

 

PS: Sorry about necro'ing, I didn't see the date because it was tagged as "hot".


Edited by Volvary, 18 January 2016 - 11:16 PM.

There are 10 types of people in the world: Those who understand binary, those who don't and those who didn't expect this to be in tertiary.


#85   Members   

33494
Like
2Likes
Like

Posted 19 January 2016 - 12:08 AM

PS: Sorry about necro'ing, I didn't see the date because it was tagged as "hot".

It's still active, so no worries. And if it wasn't hot enough already, your Mexican chili certainly does the job.

 

(I know, I know... that pun deserves a few downvotes, but it's worth it to hear your groans =P )



#86   Members   

527
Like
2Likes
Like

Posted 19 January 2016 - 02:00 AM

This is a line I commented away in a configuration script about 6 months ago. I'm glad I also put that comment because I was about to enable the report again before starting a bunch of compilations that would take about 12 hours

#this command crashes the compiler *before* it writes the compiled image to disk. Do not try to uncomment this unless you have lots of time to loose...
#report -type timing \
# -print_summary "yes" \

Definition of a man-year: 730 people trying to finish the project before lunch

#87   Members   

4064
Like
3Likes
Like

Posted 21 January 2016 - 03:03 AM

Worked on a Street Fighter 2 port a few years ago and was given the source code.  All the comments were in Japanese then above them another team that had done a different port had translated them all into Polish,  then another team had translated them all into Chinese.  Before we could start we had to translate them into English.

Another time I worked on a Sonic port which did have Engrish comments which we found humorous.  Particularly the comment for a propeller object that was constantly referred to as Properrer throughout the source.


Edited by Buster2000, 21 January 2016 - 03:03 AM.


#88   Members   

10972
Like
8Likes
Like

Posted 02 March 2016 - 05:35 PM

*
POPULAR

// TODO: Change this code before 2038.


#89   Members   

1993
Like
1Likes
Like

Posted 03 March 2016 - 05:23 AM

// TODO: Change this code before 2038.

:D :D Do you have context for this comment?



#90   Moderators   

49390
Like
2Likes
Like

Posted 03 March 2016 - 06:11 AM

 

// TODO: Change this code before 2038.

biggrin.pngbiggrin.png Do you have context for this comment?

 

I'm guessing Y2K 2: the thirty two bittening



#91   Members   

10972
Like
1Likes
Like

Posted 03 March 2016 - 11:45 AM


// TODO: Change this code before 2038.
biggrin.png:D Do you have context for this comment?

I'm guessing Y2K 2: the thirty two bittening


Yup. It was next to some 32-bit time-related code.

#92   Members   

2950
Like
1Likes
Like

Posted 05 March 2016 - 12:56 AM

To be fair, if it was using time_t then it'd solve itself by just rebuilding in a modern system... so I guess it isn't using time_t.


Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

#93   Members   

2950
Like
1Likes
Like

Posted 17 March 2016 - 05:26 PM

Looking up at the log my game just spewed out:

 

Saving configuration
Saving configuration
Saving configuration

 

Looks like I was so paranoid of certain piece of code not saving the settings properly that I just made it save them at every opportunity it had.


Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

#94   Members   

695
Like
3Likes
Like

Posted 18 March 2016 - 08:03 PM

Fixing old code, this is actually a new comment I added to remind me to not forget.

//TODO why am i doing this here? and should it not only be done once? on init?
SendMessage(This->_hwndAssetList, LVM_SETCOLUMNWIDTH, 0, 500);


#95   Members   

2670
Like
1Likes
Like

Posted 25 March 2016 - 12:19 AM

/* Warning this comment must not be removed under penalty of law. */



#96   Members   

4375
Like
1Likes
Like

Posted 11 May 2016 - 09:05 AM

sdkddkver.h

 

Microsoft added the following comment to the Windows 10 constants:

 

/* ABRACADABRA_THRESHOLD*/


"Recursion is the first step towards madness." - "Skeggǫld, Skálmǫld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/

#97   Members   

1411
Like
1Likes
Like

Posted 11 May 2016 - 09:20 AM

/* Warning this comment must not be removed under penalty of law. */

 

csc application.cs /doc:legal.xml



#98   Members   

355
Like
3Likes
Like

Posted 12 August 2016 - 07:06 AM

int dontcrash[999999]; // do not remove or relocate this array, or the code will crash at some point

 

 

 

code from my previous engine


Create your 3D RPG: Maker3D

 


#99   Members   

1411
Like
3Likes
Like

Posted 12 August 2016 - 07:55 AM

Can I borrow that dontcrash() function? I've got a production issue that would really help with.



#100   Members   

355
Like
1Likes
Like

Posted 12 August 2016 - 07:56 AM

yeah, just copy it to your code, maybe it will help


Create your 3D RPG: Maker3D