See comments inline.
--
Guy Rouillier
On 9/25/2022 3:20:31 PM, "Carlo Hogeveen" <
t...@ecarlo.nl> wrote:
>Rethinking this, the solution I use and mentioned earlier
> #ifdef LINUX
> #define WIN32 FALSE
> #endif
>has the advantage that it makes old macros work for TSE 2.6 upwards, often including Linux, and new macros can then use "#if WIN32" as a reader-friendlier alternative to "#ifndef LINUX" to test for Windows-only.
>
I don't think this is a good idea. I just grep'd all the .s* files in
the mac directory, and *all* of them test WIN32 only with #ifdef or
#ifndef. By introducing a boolean value to WIN32 that has unique
meaning (i.e., beyond the fact that it either does or does not exist),
you introduce a new avenue for logic errors. Given how long the OS
defines have been in use, the safer approach would be to restrict
testing of them only to whether they are defined or not.
>The grep macro you are working on does not support TSE 2.5 and older, as Chris' documentation mentions.
>
>That said, suppose you do want to support TSE 2.5 too.
>You can compound compiler directives this way:
> #ifdef WIN32
> #define IS_32BIT 1
> #else
> #ifdef LINUX
> #define IS_32BIT 2
> #else
> #define IS_32BIT 0
> #endif
> #endif
>
>This lets the rest of the macro use
> #if IS_32BIT
> Do TSE 2.6 upwards stuff for Windows and Linux
> #else
> Do TSE 2.5 stuff.
> #endif
Again, I think we should restrict IS_32BIT to only #ifdef or #isndef.
>
>Since compiler directives work per macro, we need not worry about what other macros do with compiler directives.
Well, here I am trying to maintain a macro I didn't write. So, some
consistent rules for writing macros would help people in a similar
situation. That's why major languages having coding styles. If, for
example, WIN32 can mean different things in different macros, that makes
keeping the entire set of macros working correctly much more difficult.
>In my opinion, requiring users to recompile your macros with "-dWIN32=0" is a bad for two reasons:
>
I agree completely. That was just a quick way for me to get the macro
working without rewriting it entirely. I would not submit that as an
official revision to that macro. I have forwarded the summary of my
work to Chris; we'll see how he would like to proceed.
Thanks for taking the time to reply. I appreciate your help.