C/C++
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives FAQs C/C++

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old July 5th, 2008, 11:39 PM
David
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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!!




Reply With Quote
  #2  
Old July 5th, 2008, 11:39 PM
Ian Collins
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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.

Reply With Quote
  #3  
Old July 5th, 2008, 11:39 PM
Ron Ford
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
Reply

Viewing: Web Development Archives FAQs C/C++ > struct with const string


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway