Jump to content

  • Log In with Google      Sign In   
  • Create Account

Best comment ever

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

#81 KuroSei   Members   -  Reputation: 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 Servant of the Lord   Crossbones+   -  Reputation: 32523

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 KuroSei   Members   -  Reputation: 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 Volvary   Members   -  Reputation: 147

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 Servant of the Lord   Crossbones+   -  Reputation: 32523

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 Daixiwen   Members   -  Reputation: 431

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 Buster2000   Members   -  Reputation: 3822

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 Nypyren   Crossbones+   -  Reputation: 10090

Like
8Likes
Like

Posted 02 March 2016 - 05:35 PM

// TODO: Change this code before 2038.


#89 Avalander   Members   -  Reputation: 1598

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 Hodgman   Moderators   -  Reputation: 48409

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 Nypyren   Crossbones+   -  Reputation: 10090

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 Sik_the_hedgehog   Crossbones+   -  Reputation: 2740

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 Sik_the_hedgehog   Crossbones+   -  Reputation: 2740

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 ExErvus   Crossbones+   -  Reputation: 614

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 Tangletail   Members   -  Reputation: 2395

Like
1Likes
Like

Posted 25 March 2016 - 12:19 AM

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



#96 Alessio1989   Members   -  Reputation: 4143

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 conquestor3   Members   -  Reputation: 1222

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







PARTNERS