Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prefixes for C/C++ data members / objects

I've been getting more and more involved in C/C++ programming lately and have noticed a trend in the way people name datatypes in their code.

I always see prefixes such as p, m, ui, etc.

For example: mPlayerNames, pData, uiNumResets

I think I get it, but just to confirm: Do these prefixes indicate the data type? i.e.:
mData -> Matrix (array) of Data
pData -> pointer to Data
uiData -> unsigned int Data
etc...

Is this correct?

like image 839
Russel Avatar asked Sep 18 '25 09:09

Russel


2 Answers

m - member of a class
p - pointer
ui - unsigned int
lpsz - long pointer string zero terminated (whew!)

I personally only use the 'm' and the 'p'. The rest is just zany in my view. It makes the code so darn hard to decipher.

I did maintenance work on this guy's code who used semi-Hungarian notation type id prefixes on every variable, function, and other identifier in the code. He used $ signs liberally to separate words. It was hard to keep the murderous rage in check.

like image 163
Amardeep AC9MF Avatar answered Sep 19 '25 22:09

Amardeep AC9MF


This is generally known as Hungarian notation.

There's nothing ironclad about the prefixes - they may vary among languages and platforms and programming shops.

And yes, your interpretations are probably correct - p and ui are common, and you'd have to check to see that m really is referring to Matrix in your environment, although it may refer to a class member.

like image 29
brainjam Avatar answered Sep 19 '25 22:09

brainjam