Thread overview | |||||
---|---|---|---|---|---|
|
May 27, 2005 C Macro to D | ||||
---|---|---|---|---|
| ||||
What is the proper way to convert this C macro to D? : #define TEXTVIEW_CLASS _T("TextView32") This is how I understand it, but don't know if it is correct: : const char[] TEXTVIEW_CLASS = "TextView32"; am I way off base here? Thanks, Andrew |
May 27, 2005 Re: C Macro to D | ||||
---|---|---|---|---|
| ||||
Posted in reply to a.c.edwards | "a.c.edwards" <a.c.edwards_member@pathlink.com> wrote in message news:d773c7$1ga7$1@digitaldaemon.com... > What is the proper way to convert this C macro to D? > > : #define TEXTVIEW_CLASS _T("TextView32") > > This is how I understand it, but don't know if it is correct: > > : const char[] TEXTVIEW_CLASS = "TextView32"; > > am I way off base here? Nope, that's about right, though that particular string would only be usable with the A versions of the API functions. If you'd like to use the W versions, you'd have to use a const wchar[]. Or, you could have a version statement: version(Unicode) { const wchar[] TEXTVIEW_CLASS="TextView32"; } else { const char[] TEXTVIEW_CLASS="TextView32"; } Which is essentially what the _T() macro does in C. You could also use the version(Unicode) statement to make aliases for the W versions of the functions (like MessageBoxW to MessageBox), and in the else, alias the A versions. That way, you can just put a -version=Unicode on the compiler commandline (or leave it out), and the correct set of functions and constants will be selected. :) |
June 02, 2005 Re: C Macro to D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote: <snip> > Or, you could have a version statement: > > version(Unicode) > { > const wchar[] TEXTVIEW_CLASS="TextView32"; > } > else > { > const char[] TEXTVIEW_CLASS="TextView32"; > } <snip> Or have somewhere version(Unicode) { alias wchar TCHAR; } else { alias char TCHAR; } then you can do simply const TCHAR[] TEXTVIEW_CLASS="TextView32"; a little less repetitive when you've got lots to declare. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
Copyright © 1999-2021 by the D Language Foundation