How to name variables which are structs

Posted by evilpie on Stack Overflow See other posts from Stack Overflow or by evilpie
Published on 2010-04-25T11:49:23Z Indexed on 2010/04/25 12:03 UTC
Read the original article Hit count: 200

Filed under:
|
|

Hello,

i often work on private projects using the WinApi, and as you might know, it has thousands of named and typedefed structs like MEMORY_BASIC_INFORMATION.

I will stick to this one in my question, what still is preferred, or better when you want to name a variable of this type. Is there some kind of style guide for this case?

For example if i need that variable for the VirtualQueryEx function.

Some ideas:

 MEMORY_BASIC_INFORMATION memoryBasicInformation;   
 MEMORY_BASIC_INFORMATION memory_basic_information;

Just use the name of the struct non capitalized and with or without the underlines.

MEMORY_BASIC_INFORMATION basicInformation;
MEMORY_BASIC_INFORMATION information;

Short form?

 MEMORY_BASIC_INFORMATION mbi;

I often see this style, using the abbreviation of the struct name.

 MEMORY_BASIC_INFORMATION buffer;

VirtualQueryEx defines the third parameter lpBuffer (where you pass the pointer to the struct), so using this name might be an idea, too.

Cheers

© Stack Overflow or respective owner

Related posts about c

    Related posts about winapi