Avoid misleading messages about properties being already defined#864
Merged
bcoconni merged 2 commits intoJSBSim-Team:masterfrom Mar 24, 2023
Merged
Avoid misleading messages about properties being already defined#864bcoconni merged 2 commits intoJSBSim-Team:masterfrom
bcoconni merged 2 commits intoJSBSim-Team:masterfrom
Conversation
Member
|
Looks good. |
Codecov Report
@@ Coverage Diff @@
## master #864 +/- ##
==========================================
- Coverage 23.24% 23.24% -0.01%
==========================================
Files 167 167
Lines 19603 19607 +4
==========================================
Hits 4557 4557
- Misses 15046 15050 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/variableand sets its value to1.0.However if the property
system/variablealready 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 definedto avoid overriding the property initialization (possibly with an inconsistent value).Alternatively, JSBSim allows declaring a property without the
valueattribute: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/variablealready 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/variablealready 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
overridetooverride_propssince, as @ermarch mentioned in the discussion #854,overrideis a C++ identifier since C++11. Strictly speakingoverrideis not a reserved keyword and compilers do not issue warning messages when usingoverrideas 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++) 😉 ?