Handmade Hero»Forums»Code
1 posts
Day 007 - LPDIRECTSOUND versus IDirectSound*
Is it just a matter of preference/coding style or, are there other reasons to use the Windows typedef over the more explicit version?

link to the documention:
Mārtiņš Možeiko
2383 posts / 2 projects
Day 007 - LPDIRECTSOUND versus IDirectSound*
Typedef's are only matter of preference/code style. There are no other reasons for any typedef.
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Day 007 - LPDIRECTSOUND versus IDirectSound*
Yes, the fact that Windows does all this LPSOMETHING nonsense because of Microsoft's early adoption of Hungarian Notation. "LP" means "long pointer", the "long" part not really meaning anything anymore (it had meaning in the old days when PC memory addressing wasn't flat - there were "near" and "far" pointers which were addressed differently).

Personally, I find "Systems Hungarian Notation" to be a very bad idea, because it obscures the real types of things and makes the programmer have learn yet another nomenclature instead of just having the proper C type so it's clear (eg., we all know what * is if we program C at all, but most of us wouldn't know what LP is if we've never programmed on Windows!)

- Casey
504 posts
Day 007 - LPDIRECTSOUND versus IDirectSound*
And I stands for Interface

Also there are 2 types of hungarian notation: system and apps

System is where the prefix is literally the type of the variable, and frankly useless in strongly typed languages. The compiler knows about that and will error when there is a mixup, an editor with a well implemented go-to-definition will let you find out in a second.

Apps hungarian is where the prefix is what the variable is used for. For coordinates that would include which coordinate space they are in, whether they are absolute or an offset. That way it should be easier to see mixups where for example you add a position to another position. I'm not truly sure about how useful it really is because the code I work with almost never has multiple variables of the same type that are incompatible like that (which says something by itself).