without explicit #undef
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
without explicit #undef
Hi I am trying to figure out why I have a lot of these errors eg
here is an example of the log
Does this mean I need an ID or something in these macros?warning preprocessor: Redefining macro CALCULATE_INCOME_BONUS_WESNOTH without explicit #undef
here is an example of the log
Code: Select all
20190714 11:11:17 warning preprocessor: Redefining macro CALCULATE_INCOME_BONUS_WESNOTH without explicit #undef at ~add-ons/Conquestplus/scenarios/conquest_wesnoth_winter.cfg:593
included from ~add-ons/Conquestplus/_main.cfg:7
previously defined at ~add-ons/Conquestplus/scenarios/conquest_wesnoth_II.cfg:599
included from ~add-ons/Conquestplus/_main.cfg:7
20190714 11:11:18 warning preprocessor: Redefining macro CALCULATE_INCOME_BONUS_DESERT_EMPIRES without explicit #undef at ~add-ons/Conquestplus/scenarios/desert_empires2.cfg:1762
included from ~add-ons/Conquestplus/_main.cfg:7
previously defined at ~add-ons/Conquestplus/scenarios/desert_empires.cfg:1764
included from ~add-ons/Conquestplus/_main.cfg:7
20190714 11:11:20 warning preprocessor: Redefining macro CALCULATE_INCOME_BONUS_FAERIE without explicit #undef at ~add-ons/Conquestplus/scenarios/pirate_islands.cfg:823
included from ~add-ons/Conquestplus/_main.cfg:7
previously defined at ~add-ons/Conquestplus/scenarios/faerie.cfg:837
included from ~add-ons/Conquestplus/_main.cfg:7
20190714 11:11:28 warning preprocessor: Redefining macro ABILITY_LEADERSHIP_LEVEL_1 without explicit #undef at ~add-ons/Conquestplus_space/utils/abilities.cfg:14
included from ~add-ons/Conquestplus_space/_main.cfg:5
previously defined at core/macros/deprecated-utils.cfg:63
included from core/_main.cfg:18
included from _main.cfg:18
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
Re: without explicit #undef
It says you define macro with same name at
~add-ons/Conquestplus/scenarios/conquest_wesnoth_winter.cfg:593 and
~add-ons/Conquestplus/scenarios/conquest_wesnoth_II.cfg:599
It works as warning in case you unintentionally used already existing macro name.
If you want to silence that warning, #undef CALCULATE_INCOME_BONUS_WESNOTH.
~add-ons/Conquestplus/scenarios/conquest_wesnoth_winter.cfg:593 and
~add-ons/Conquestplus/scenarios/conquest_wesnoth_II.cfg:599
It works as warning in case you unintentionally used already existing macro name.
If you want to silence that warning, #undef CALCULATE_INCOME_BONUS_WESNOTH.
Re: without explicit #undef
so I have a leadership macro to replace the deprecated version
then at the end of the abilities.cfg under the above I added
Code: Select all
#define ABILITY_LEADERSHIP_LEVEL_1
# included in an [abilities] clause
[leadership]
value=25
affect_allies=yes
affect_enemies=no
affect_self=no
cumulative=no
name= _ "Leadership"
female_name= _ "Female^Leadership"
description= _ "This unit can lead your own units that are next to it, making them fight better.
Adjacent own units of lower level will do more damage in battle. When a unit adjacent to, of a lower level than, and on the same side as a unit with Leadership engages in combat, its attacks do 25% more damage times the difference in their levels."
[affect_adjacent]
adjacent=n,ne,se,s,sw,nw
[/affect_adjacent]
[/leadership]
#enddef
However then ruuning the mod I get a load of errors saying the leadership macro is now missing and the log says#undef ABILITY_LEADERSHIP_LEVEL_1
Just wondering if I am doing this #undef thing properly?20190714 18:48:19 error preprocessor: Macro/file 'ABILITY_LEADERSHIP_LEVEL_1' is missing
at ~add-ons/Chaoz/utils/menu_macro_missile.cfg:129
included from ~add-ons/Chaoz/_main.cfg:5
included from ~add-ons/Chaoz/utils/menu_spells_law.cfg:4
included from ~add-ons/Chaoz/_main.cfg:5
included from ~add-ons/Chaoz/utils/menu_spells.cfg:80
included from ~add-ons/Chaoz/_main.cfg:5
included from ~add-ons/Chaoz/scenarios/Chaoz_2p_Hamlets.cfg:15
included from ~add-ons/Chaoz/_main.cfg:7
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
Re: without explicit #undef
After you undef it, it does not exist anymore. So you want to undef it at correct time only. Compare https://github.com/ProditorMagnus/Agele ... fg#L84-L94
Re: without explicit #undef
Hm can't see #undef anywhere in that code...
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
Re: without explicit #undef
First and last line of the snippet include files which have undef. This itself shows the order in which they are included.
I am not completely sure if it is important to put core macros back after processing my addon, but better be safe.
I am not completely sure if it is important to put core macros back after processing my addon, but better be safe.
Re: without explicit #undef
hm I'm not sure I can undefine most of these macros e.g. leadership replacement is used at any time of the game... as is the bonus gold stuff (used to calculate bonus gold when all vilas in a 'region' are captured).
I there not a way of supressing this/specific kinds of errors? Just good to keep log clean so I can see any proper issues vs spamming this all thro the log...
I there not a way of supressing this/specific kinds of errors? Just good to keep log clean so I can see any proper issues vs spamming this all thro the log...
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
Re: without explicit #undef
If you for some reason want to re-use core macro name, then steps are
1) #define content of old macro under new name
2) #undef old name
3) #define new content under old name
4) load your addon
5) #undef old name
6) #define old saved content under old name
7) #undef new name
It is usually much easier to use different name.
If it is your own macro, then feel free to #undef it right before #define.
1) #define content of old macro under new name
2) #undef old name
3) #define new content under old name
4) load your addon
5) #undef old name
6) #define old saved content under old name
7) #undef new name
It is usually much easier to use different name.
If it is your own macro, then feel free to #undef it right before #define.
Re: without explicit #undef
thanks that seems to sort out the #undef error for leadership, which I'd added as a custom macro as it's being deprecated... simply by adding #undef MACRONAME before the macro... presumably disabling the core one I spose..
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
Re: without explicit #undef
The #define statements are handled by the preprocessor, which happens when Wesnoth says "Reading files and creating cache". At this point, all of the WML files are merged in to a single file, and any #defined macros are expanded. All of the #defines have been replaced before any of your WML is run.
Re: without explicit #undef
No, please don't do this. If the content of the macro in core changes, anything that uses your addons will then use the old version of the core macro, which could cause all sorts of errors. As Ravana says, just define your own macros with different names.
Re: without explicit #undef
That is exactly the worst thing to do, that could break all the addons that are loaded after yours.
Re: without explicit #undef
Thanks will rename the local one vs use of undef...
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
Re: without explicit #undef
I wonder if the preprocessor should implicitly start a macros scope when it starts reading an addon and end that scope when it finishes reading the addon. This way, #define's from one addon will never be in force for other addons, unless the second addon explicitly does {~add-ons/FirstAddOn/foo.cfg}.
Re: without explicit #undef
I tried out that they actually are in separate scope. So we can just override it however we want.