From: Giovanni Dicanio on
"David Webber" <dave(a)musical-dot-demon-dot-co.uk> ha scritto nel messaggio
news:Ot2PUpq1KHA.6108(a)TK2MSFTNGP06.phx.gbl...

> This is a philosophical question I have been wrestling with. I have
[...]
> Now I *suppose* one could start using DeleteFile() with wchar_t (now that
> UNICODE is defined), but that would effectively be making the assumption
> that DeleteFileA() and DeleteFileW() will eventually disappear, leaving
> DeleteFile() once again as the only genuine version of the API function,
> but now taking wchar_t strings. Has in fact the future been thus
> defined?

Dave:

IMHO, if you don't need to support old platforms like Windows 95/98 (more
than 10 years old!), it is just fine to use wchar_t/WCHAR and DeleteFile (or
whatever API, without the "W" suffix).
Note that more modern APIs exist only in the Unicode form, e.g. :
DrawThemeText function (see the 'LPCWSTR pszText' parameter):

http://msdn.microsoft.com/en-us/library/bb773312(VS.85).aspx

Giovanni


From: Giovanni Dicanio on
"Joseph M. Newcomer" <newcomer(a)flounder.com> ha scritto nel messaggio
news:uefqr51j6ol89h9ac0t93c2qs0015abbf6(a)4ax.com...

> Actually, you would be using WCHAR, LPWSTR, and LPCWSTR. There is very
> little reason in
> Windows programming to ever use wchar_t as a data type.

Why?
Do you use INT instead of int?
Or BOOL instead of bool?
Or VOID instead of void?

I fail to see a reason why one should use WCHAR instead of wchar_t (to me,
probably the only reason is that it is shorter to type :)
I mean: I see this just as a personal programming style.

Note also that if you read Google C++ Coding Style document, in particular
the section about Windows code:

http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Windows_Code

they tend to prefer 'const WCHAR *' instead of LPCWSTR (and frankly
speaking, I find it more readable and its intent more clear, especially to a
Win32 beginner programmer).

My 2 cents,
Giovanni



From: Goran on
On Apr 8, 11:37 am, "Giovanni Dicanio"
<giovanniDOTdica...(a)REMOVEMEgmail.com> wrote:
> "Joseph M. Newcomer" <newco...(a)flounder.com> ha scritto nel messaggionews:uefqr51j6ol89h9ac0t93c2qs0015abbf6(a)4ax.com...
>
> > Actually, you would be using WCHAR, LPWSTR, and LPCWSTR.  There is very
> > little reason in
> > Windows programming to ever use wchar_t as a data type.
>
> Why?
> Do you use INT instead of int?
> Or BOOL instead of bool?
> Or VOID instead of void?
>
> I fail to see a reason why one should use WCHAR instead of wchar_t (to me,
> probably the only reason is that it is shorter to type :)
> I mean: I see this just as a personal programming style.
>
> Note also that if you read Google C++ Coding Style document, in particular
> the section about Windows code:
>
>  http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Window....
>
> they tend to prefer 'const WCHAR *' instead of LPCWSTR (and frankly
> speaking, I find it more readable and its intent more clear, especially to a
> Win32 beginner programmer).

I don't care about const WCHAR* versus LPCWSTR either (and it should
be noted that this L there stands out like a sore thumb).

The part about exceptions is clueless, though. There is no C++ without
exceptions, and it's not MS implementation of STL that throws, it's
__ANY__ implementation. I mean, how do they think that e.g.
vector::push_back should react if it has to re-allocate contents and
that fails? That will throw an exception, MS or not, or die with
segmentation fault if operator new is rigged to return NULL on
failure. (Under a system with overcommit, e.g. Linux, it might be that
process will be killed __later__ by OOM killer, but that's something
else).

WRT exceptions, their style guide has serious delusions. It is frankly
amazing that such a well-known document from a major company contains
such drastic logic flaws.

I think I know where they are coming from - they think that, because
they have big code base that is not exception safe, they can just
waive exceptions out by saying "thou shalt not throw". But the problem
is, they themselves will use libraries (e.g. STL), or cpp runtime,
that throw (per standard, operator new shall throw - what then? The
best they can do is to rig it to terminate the process, I guess).
Google should sort themselves out there.

Goran.
From: Doug Harrison [MVP] on
On Thu, 8 Apr 2010 11:37:02 +0200, "Giovanni Dicanio"
<giovanniDOTdicanio(a)REMOVEMEgmail.com> wrote:

>Note also that if you read Google C++ Coding Style document, in particular
>the section about Windows code:
>
> http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Windows_Code

Wow, that page looks like a 100,000 character run-on sentence in Firefox.
Then I saw the NoScript "blocked" icon in the status bar. Great program,
but you always have to remember that if a site you haven't been to doesn't
look or work right, it's probably NoScript. :) (Unblocking googlecode.com
fixed it, of course.)

>they tend to prefer 'const WCHAR *' instead of LPCWSTR (and frankly
>speaking, I find it more readable and its intent more clear, especially to a
>Win32 beginner programmer).

It does speak for itself. The problem with complex typedefs is that if you
use them at all, you must use them everywhere. If you had LPWSTR but not
LPCWSTR, it would be a huge mistake to try to fake it as "const LPWSTR".

--
Doug Harrison
Visual C++ MVP
From: Joseph M. Newcomer on
See below...
On Thu, 8 Apr 2010 11:37:02 +0200, "Giovanni Dicanio"
<giovanniDOTdicanio(a)REMOVEMEgmail.com> wrote:

>"Joseph M. Newcomer" <newcomer(a)flounder.com> ha scritto nel messaggio
>news:uefqr51j6ol89h9ac0t93c2qs0015abbf6(a)4ax.com...
>
>> Actually, you would be using WCHAR, LPWSTR, and LPCWSTR. There is very
>> little reason in
>> Windows programming to ever use wchar_t as a data type.
>
>Why?
>Do you use INT instead of int?
>Or BOOL instead of bool?
>Or VOID instead of void?
****
Depends on what standard I'm trying to follow. But wchar_t does not exist in any API
parameter list or as a return type; LPTSTR is the encoding-neutral form, and if you read
any code it uses LPWSTR and LPCWSTR as the parameter types. Therefore, it is unnatural in
writing WIndows code to drop down to the low-level implmentation. I also do not use
'unsigned int' for UINT, 'unsigned long' for ULONG or DWORD, and so on. When interfacing
to API calls, I use BOOL if the call uses BOOL (and I don't use bool unless I'm writing
std::-related code)
****
>
>I fail to see a reason why one should use WCHAR instead of wchar_t (to me,
>probably the only reason is that it is shorter to type :)
>I mean: I see this just as a personal programming style.
****
Consistency with Windows programming styles.
****
>
>Note also that if you read Google C++ Coding Style document, in particular
>the section about Windows code:
>
> http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Windows_Code
****
I'm supposed to take SERIOUSLY a style guide that does not allow pass-by-reference EXCEPT
for const references? In fact, non-const references are very powerful and very important
to me.

The only comment I found about 'const' was that it should be used wherever it makes sense.
If there was something else to say, it was obviously not important enough to say in the
document. Because of security, the silly buttons did nothing. Silly buttons like this
serve no useful purpose except to look cute.
****
>
>they tend to prefer 'const WCHAR *' instead of LPCWSTR (and frankly
>speaking, I find it more readable and its intent more clear, especially to a
>Win32 beginner programmer).
>
****
And this opinion of one programmer proves what? Note that noplace in the Win32 API is
const WCHAR * used; instead, LPCWSTR is used.
joe
****
>My 2 cents,
>Giovanni
>
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8
Prev: Setting PropertySheet Title (Wizard mode)
Next: strsafe.lib