Re: #defines and strings



In article <1120136034.488821.20890@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
GMM50 <george.martin@xxxxxxx> wrote:
>In the code I use these messages as constants as:
> PlayMsg(SM1023, OutputChannel, Volume);
>So I'm planning to use a define to convert SM1023 to the internal
>storage number (= location).

>#define SM1023 19 // Hello Message

>But then when the user downloads a message I need to programatically
>determine it's internal storage number (= location).

>struct MSG_CVRG MsgTbl[] = {
> 1023, 19; // Hello Message
> 0, 0;
>}

>My problem is I now have data in two places and they will get out of
>sync.


Perhaps I'm missing something, but why not use

struct MSG_CVRG MsgTbl[] = {
1023, SM1023, // Hello Message
0, 0,
};

(Note: semicolons converted to commas)


Potentially you might also want to consider

#define PASTE(T1,T1) T1##T2
#define DclMsg(N) {N, PASTE(SM,N)}

struct MSG_CVRG MsgTbl[] = {
DclMsg(1023),
DclMsg(1196),
DclMsg(1197),
{0, 0},
};


Also, you might not need the trailing {0, 0} as you can take
sizeof(MsgTabl) / sizeof(struct MSG_CVRG)
to find out how many elements there are.
--
The rule of thumb for speed is:

1. If it doesn't work then speed doesn't matter. -- Christian Bau
.



Relevant Pages

  • raid5 on a3000
    ... I'm running a mail server and web server for 30k users on a E450 using ... planning to use 2 drives as hot spares. ... What would be the best configuration for the new storage. ... I have temporarily disabled user quotas as boot up is ...
    (SunManagers)
  • Re: Gameroom almost complete
    ... pictures are of the storage bin I rented for 2 and half years. ... bins email me. ... As mentioned I will be loading the gameroom with around 40 total machines. ... all the planning in the world wont make a difference...Thanks for reading ...
    (rec.games.pinball)
  • Enterprise Virtualization: Making it a reality
    ... by introducing virtualization to their server, storage, application, ... and desktop environments. ... How are we planning for this? ...
    (rec.radio.shortwave)
  • Re: When do 2 TB drives arrive on the market?
    ... Previously Andrew Hamilton wrote: ... planning for this year and next year? ... I need to build a storage ... server with at least 4 TB, but I don't want it to have so many drives ...
    (comp.sys.ibm.pc.hardware.storage)