[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
Re: [XaraXtreme-dev] Patch for spelling and white space consistency
- From: Phil Martin <phil@xxxxxxxx>
- Date: Fri, 31 Mar 2006 06:28:34 +0100
- Subject: Re: [XaraXtreme-dev] Patch for spelling and white space consistency
Hi Carl,
One of our other guidelines is that only one variable should be
declared per line, partly to address the issue you have pointed out.
So your example would be:
TCHAR* ptr1;
TCHAR* ptr2;
This allows our "star next to var" style to be used consistently
throughout.
Phil
On 31 Mar 2006, at 01:32, Carl Worth wrote:
On Wed, 29 Mar 2006 12:48:09 +0100, Phil Martin wrote:
TCHAR* variable; // Correct
TCHAR *variable; // Incorrect
The logic for this one is that the variable you are declaring is a
pointer to a TCHAR (it will be the size of a pointer) and so it makes
more sense for the code to express that.
It would be nice if the syntax for variable declarations allowed this
style to be used consistently this way. But, unfortunately, this style
can lead to mistakes such as:
TCHAR* ptr1, ptr2;
Which has the appearance of declaring two symmetric pointers to TCHAR
but in face declares one pointer to TCHAR and one TCHAR.
This is why I greatly prefer a style which would have the correct
version of the code be:
TCHAR *ptr1, *ptr2;
-const TCHAR *cc_lstrstr(const TCHAR *String1, const TCHAR
*String2);
+const TCHAR* cc_lstrstr(const TCHAR *String1, const TCHAR
*String2);
In the case of a function's return value, I definitely agree that the
'*' belongs next to the type and not next to the function name.
-Carl