6

In plain C, I will name a struct like this:

struct MyStruct
{
    int something;
};

But, since I'm now programming under Windows, I want my code to be very consistent in which refers to naming conventions. So, my variables are now named using mixedCase instead of lower_case and my functions are now using CapWords. I have seen some structs with all capital letters, but I don't like this very much because I reserve that for constants and macros.

Thanks.

cdonts
  • 9,304
  • 4
  • 46
  • 72
  • 1
    This question, as it is stated, invites a lot of opinion. As long as you stay away from reserved or keyword names, such as SOMETHING_t (where using the `_t` as a suffix is a little touchy sometimes), or `struct` _struct_ . I favor (even though you do not) `typedef struct {...}ANY_NAME;//using caps.` Then use `ANY_NAME` to create instances like this: ANY_NAME any, *pAny; – ryyker Jan 21 '14 at 22:56
  • So should I use `ALL_CAPS`, right? – cdonts Jan 21 '14 at 23:29
  • 1
    I'm not sure if there's a single naming convention used even within only the Windows SDK - so you might be able to justify whatever you like with . – Michael Burr Jan 22 '14 at 00:59

2 Answers2

4

Check out this link if you want a reference on Naming Conventions in C.

As long as you're consistent with using CamelCase of under_score conventions for whatever purpose, it doesn't really matter.

What are the most common naming conventions in C?

Community
  • 1
  • 1
Seyon
  • 481
  • 6
  • 13
3

Here is a similar question: Naming convention for Win32/MFC with C++
MSDN naming guideline locates at http://msdn.microsoft.com/en-us/library/ms229002(v=vs.110).aspx
Struct naming convention is described at http://msdn.microsoft.com/en-us/library/ms229040(v=vs.110).aspx

Community
  • 1
  • 1
vad
  • 344
  • 2
  • 12