Brett McCoy wrote:
> On Nov 15, 2007 3:42 PM, debasish deka <[EMAIL PROTECTED]> wrote:
>
>> #define P 1 or 2 etc
>> so that while writing the associated handlers I can just write COM##P which
>> would be understood by the preprocessor as COM1 or COM2 etc. and implemented
>> accordingly in the program. So thats all. Instead of modifying at many
>> parts of the program we just change the number 'n'.
>
> #define MKPORT (P) COM##P
>
> so MKPORT(1) will get replaced with COM1
>
> COM1 should be either another macro (which will require a re-scan of
> the preprocessor when compiling) or a valid identifier (variable or
> constant).
>
> I don't think the token pasting operator can be used outside of a
> macro definition, i.e.,
>
> switch(com) {
>
> case COM##P: ...
> }
>
> -- Brett
> ------------------------------------------------------------
> "In the rhythm of music a secret is hidden;
> If I were to divulge it, it would overturn the world."
> -- Jelaleddin Rumi
Token pasting is exclusively for use within preprocessor macros. That
said, the use of #define's should be pretty limited.
Someone mentioned templates. I'll have to look into that as an option
for some crazy macros I'm currently using. It would be nice for VAX to
recognize certain segments of code. I doubt templates will help very
much, though.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/