Discarding typedef for enums? #1566
Replies: 4 comments 8 replies
-
I wonder how much effort it would be to change those to |
Beta Was this translation helpful? Give feedback.
-
That would be better yes, and if we are concerned both about type safety and it being strongly-typed as well, then typed enums would be more appropriate: enum enumName: <dataType> { memberA, memberB, ... }; In addition to the assignment of a specific type, this would also avoid the slight verboseness of scoping that comes when using members ( |
Beta Was this translation helpful? Give feedback.
-
We could replace them with enums of the form:
without major change to the code. These |
Beta Was this translation helpful? Give feedback.
-
It might also be better to make that small change in the .tmpl files that account for the template structure or the code segment in the autocoder (assuming* that to be the source that generates them, could be code in FPP too ig) which produces the 'typedef enum' constructs for the .cpp/.hpp files. (to keep things consistent for future autogenerated C++ code if this change is considered across all files) The generation for the enum constructs (along with other model-based autocoder-emitted code) in the current version of fprime appears to be from FPP to XML (stored somewhere in the build cache), and then XML to C++, parsed and generated through the Python scripts or the autocoders (although it seems there have been efforts to remove the XML in between, and the FPP-based model itself would be used to directly generate the enums in the C++ files in the long run - like not integrated into the fprime build system yet, but not too far off maybe?) While going through the Math Component tutorial, I noticed that the .fpp file specification included just an 'enum', but for what I saw, the automatically generated header file |
Beta Was this translation helpful? Give feedback.
-
If we are dealing with C++ and not C at any point (assuming, as the deployments have to do with instances of the components or C++ classes), can we discard the
typedef
part when declaring enums? (e.g.)(Given that C++ can achieve the goal of discarding the prepended use of
enum
keyword without explicitly creating an alias)Beta Was this translation helpful? Give feedback.
All reactions