|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
struct with const string
Hello,
Looking for a solution to take something like: const TCHAR StrArrayZ[]=_T("Item1\0Item2\0Item3\0"); and convert it to something like: #include <align1.h> struct { union { const TCHAR StrArrayZ[1]; struct { const TCHAR I1[]=_T("Item1"); const TCHAR I2[]=_T("Item2"); const TCHAR I3[]=_T("Item3"); const TCHAR Z[]=_T(""); }s; } u; } SItems; #include <alignend.h> So I could replace the original StrArrayZ with SItems.u.StrArrayZ, but could also deference each item directly via SItems.u.s.I1, etc Is it possible to use the compiler to do it similar to above??? TIA!! |
|
#2
|
|||
|
|||
|
struct with const string
David wrote:
Hello, > > Looking for a solution to take something like: > const TCHAR StrArrayZ[]=_T("Item1\0Item2\0Item3\0"); > What does that line do? Neither TCHAR or _T are standard C. and convert it to something like: > #include <align1.h> > struct { union { const TCHAR StrArrayZ[1]; struct { const TCHAR I1[]=_T("Item1"); const TCHAR I2[]=_T("Item2"); const TCHAR I3[]=_T("Item3"); const TCHAR Z[]=_T(""); }s; } u; } SItems; > #include <alignend.h> > So I could replace the original StrArrayZ with SItems.u.StrArrayZ, but could also deference each item directly via SItems.u.s.I1, etc > Is it possible to use the compiler to do it similar to above??? > You'd have to write your own code generator. -- Ian Collins. |
|
#3
|
|||
|
|||
|
struct with const string
Sat, 5 Jul 2008 21:14:34 -0700, David posted:
Hello, > > Looking for a solution to take something like: > const TCHAR StrArrayZ[]=_T("Item1\0Item2\0Item3\0"); > and convert it to something like: > #include <align1.h> > struct { union { const TCHAR StrArrayZ[1]; struct { const TCHAR I1[]=_T("Item1"); const TCHAR I2[]=_T("Item2"); const TCHAR I3[]=_T("Item3"); const TCHAR Z[]=_T(""); }s; } u; } SItems; > #include <alignend.h> > So I could replace the original StrArrayZ with SItems.u.StrArrayZ, but could also deference each item directly via SItems.u.s.I1, etc > Is it possible to use the compiler to do it similar to above??? > TIA!! Yikes. align1.h? struct union const TCHAR? This is C salad. -- I go on working for the same reason that a hen goes on laying eggs. H. L. Mencken |
![]() |
| Viewing: Web Development Archives > FAQs > C/C++ > struct with const string |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|