EVerest / cbexigen

cbExiGen - The V2GTP EXI codec generator for cbV2G
Apache License 2.0
32 stars 18 forks source link

Implement struct with typedef struct to make syntax cleaner #76

Closed andreichalapco closed 6 months ago

andreichalapco commented 7 months ago

Describe the problem

Hi, So i've used the generator for the ISO15118-2 and generate some messages. I immediately saw that within iso2_msgDefDatatypes.h there exists the following declarations for structs:

struct iso2_CostType {
    // costKind, costKindType (base: string)
    iso2_costKindType costKind;
    // amount, unsignedInt (base: unsignedLong)
    uint32_t amount;
    // amountMultiplier, unitMultiplierType (base: byte)
    int8_t amountMultiplier;
    unsigned int amountMultiplier_isUsed:1;
};

This syntax is clear for the declaration but a typedef declaration will make the use of this struct type more readable when implemented within other structs. The idea is not to always usestruct name_type when used within other structs or function signatures.

Describe your solution

I can modify the generator if this is allowed to make a pull request if needed. The only problem with this change is: if this fix will trigger some global namespace problems (if enums with same name as structs exists, but I don't think so)

Additional context

No response

andreichalapco commented 6 months ago

Seems like a very used pattern ... my fault ... don't have a lot of experience in C.