Avoid misleading messages about properties being already defined #864
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
JSBSim issues warning messages
"Property x/y/z is already defined"
when encountering a property definition in an definition XML file while the property exists.This warning message puzzles users as it is not obvious to understand what this message exactly means. This has been reported several times:
The code that issues this warning message is located in
jsbsim/src/input_output/FGPropertyReader.cpp
Lines 86 to 110 in e1af7ce
It is a feature that allows to specify the initial value of a property:
This statement is very similar to a variable declaration in C++ such as
double x=1.0;
.When JSBSim meets this statement, it creates the property
system/variable
and sets its value to1.0
.However if the property
system/variable
already exists then JSBSim considers that the property has already been defined (and possibly initialized) elsewhere. So JSBSim ignores this XML statement and issues a warning messageProperty system/variable is already defined
to avoid overriding the property initialization (possibly with an inconsistent value).Alternatively, JSBSim allows declaring a property without the
value
attribute:This variant of the statement is similar to a C++ variable declaration without an initialization such as
double x;
. It is meant to tell JSBSim to create a property if it does not already exist. This is useful because some XML statements might need a property to exist at the moment of their creation while the property is actually defined at some other place in the XML aircraft definition files. Once again, this is very similar to the declaration of a C++ global variable or function.If the property
system/variable
already exists then JSBSim issues the warning messageProperty system/variable is already defined.
The point of this PR is that it is useless to issue this warning message when the XML statement does not specify the
value
. As nothing wrong can derive from ignoring the XML statement<property> system/variable </property>
when the propertysystem/variable
already exists.This would save a number of warning messages that are issued when loading some FDM, including some of the example models that are distributed with JSBSim.
I also took opportunity of this PR to rename the variable
override
tooverride_props
since, as @ermarch mentioned in the discussion #854,override
is a C++ identifier since C++11. Strictly speakingoverride
is not a reserved keyword and compilers do not issue warning messages when usingoverride
as a variable name (neither gcc, nor MSVC or clang). However it is most likely not good practice to do so as it might bring confusion. What about(which is legal in C++) 😉 ?