Open-GTO / foreach

foreach standalone include (non y_iterate version)
Other
22 stars 8 forks source link

YSI communication missing breaks builds #2

Closed Y-Less closed 7 years ago

Y-Less commented 7 years ago

I've had multiple reports of problems, which people attributed to both the new compiler and YSI:

https://github.com/Zeex/pawn/issues/164 https://github.com/Misiur/YSI-Includes/issues/166

After investigation, I found out it was this:

http://forum.sa-mp.com/showpost.php?p=3768059

Can you please put the headers back in, people are used to just having both working fine, with whichever is newer being used. Or at least some reduced headers so YSI can query that file, but your version won't query YSI if you really don't want YSI being used. Maybe just:

#define _FOREACH_LOCAL_VERSION 19

// Foreach is testing us.
#if defined _FOREACH_INC_TEST
    #define _FOREACH_CUR_VERSION _FOREACH_LOCAL_VERSION
    #endinput
#endif
#define _FOREACH_INC_TEST

#if !defined _samp_included
    #error "Please include a_samp or a_npc before foreach"
#endif
Y-Less commented 7 years ago

That will also cover the reinclusion case, so the _foreach_included check isn't needed any more (which is good, because I might have to add something to detect and complain about that symbol to YSI).

ziggi commented 7 years ago

I don't understand why people uses foreach and YSI together but ok, I will add some checks.

And I want to save ability to include foreach twice, so I think that something like that is better:

#if defined _FOREACH_LOCAL_VERSION
    #endinput
#endif
#define _FOREACH_LOCAL_VERSION 19

// Foreach is testing us.
#if defined _FOREACH_INC_TEST
    #endinput
#endif

#if !defined _samp_included
    #error Please include a_samp or a_npc before foreach
#endif

What do you think?

Y-Less commented 7 years ago

People don't really use them together, but a lot of people tend to have both downloaded from various sources and modes. The code I posted already has an include guard in it so you can't include it twice.

ziggi commented 7 years ago

The code I posted already has an include guard in it so you can't include it twice.

But if I will include twice (with your code), I will get _FOREACH_LOCAL_VERSION already defined error.

Y-Less commented 7 years ago

You shouldn't do - that only happens if the two definitions are different. Two identical defines are ignored.

ziggi commented 7 years ago

I didn't know about this, thanks.