Variable prefixes in (Microsoft) Visual C++

Posted on 2003-03-06
Medium Priority
Last Modified: 2013-12-14
I have recently had to undertake a project using Visual C++, a language and programming paradigm that I'm not yet familliar with.  My question should be fairly basic for anyone involved in Visual C++ programming or possibly programming in general.

I have seen many prefixes on variables such as:


... and many (all?) of these variables have been declared using some of:


So my question is this:  Is there a good reference on what the individual prefixes and macros for declaration mean?

Question by:Sparky961
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Expert Comment

ID: 8081299
Try MSDN(Microsoft Developer Network)


Author Comment

ID: 8081776
I have already been wandering through the endless maze of MSDN quite a bit.  I was hoping for a summary from someone that already knows this information instead of the lengthy process of piecing together this information.

LVL 12

Accepted Solution

Salte earned 200 total points
ID: 8082071
This is the so-called hungarian notation.

Note that microsoft has departed from that notation in .NET. It is a thing of the past and personally I think it is good. The names tended to be very 'artificial' and if you write small functions or with declarations close to where they are used there should be no need to indicate by the name what type the variable is. If you put the declaration far away from where it is used, perhaps you should rather move the declaration.

From this you might think that global variables should still have the prefix but I would say no.

Global variables should in general be very few and only rarely of simple types. Most global variables should be classes which are specific anyway and it isn't really much information to use a prefix to say that 'this variable is a class'. What is interesting to know then is WHAT class. However, even for global variables, if they are reasonably named then you can usually guess the type.

a name like 'distance' is some form of scalar type and measure the distance in some form related to the program. There's no need to say that it is integer or double, that kind of info is just disturbing so 'iDistance' or 'dblDistance' wouldn't make much sense.

Anyway, Microsoft has full documentation about each prefix and what they mean. Please note though that that info isn't absolute, I have seen code from microsoft which didn't always follow all those recommendations completely.

Anyway, I will strongly urge you to NOT use hungarian notation in your own code. It might be useful to know when you read MS code though but don't use it yourself.

Once again a MS feature which is largely useless :-)


Author Comment

ID: 8082177
If someone can point me directly to a list, they can have the points...


Author Comment

ID: 8082209
Unfortunately, the project that I'm working on started it's life as a template and I don't think it would be wise to change variable names at this stage. ;)

I thank you for the explanation, and I have FINALLY found a reference for all of these prefixes.


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question