NordicSemiconductor / zcbor

Low footprint C/C++ CBOR library and Python tool providing code generation from CDDL descriptions.
Apache License 2.0
114 stars 34 forks source link

sample "pet" fails to build #370

Closed markuckermann closed 7 months ago

markuckermann commented 11 months ago
mkdir build
cmake . -Bbuild -DREGENERATE_ZCBOR=Y
make -C build

Results in

[ 87%] Building C object CMakeFiles/app.dir/src/main.c.o
/zcbor/samples/pet/src/main.c:24:7: error: use of undeclared identifier 'Pet_species_cat_c'; did you mean '_Pet_species_cat'?
        case Pet_species_cat_c:
             ^~~~~~~~~~~~~~~~~
             _Pet_species_cat
/zcbor/samples/pet/include/pet_types.h:37:3: note: '_Pet_species_cat' declared here
                _Pet_species_cat = 1,
                ^
/zcbor/samples/pet/src/main.c:27:7: error: use of undeclared identifier 'Pet_species_dog_c'; did you mean '_Pet_species_dog'?
        case Pet_species_dog_c:
             ^~~~~~~~~~~~~~~~~
             _Pet_species_dog
/zcbor/samples/pet/include/pet_types.h:38:3: note: '_Pet_species_dog' declared here
                _Pet_species_dog = 2,
                ^
/zcbor/samples/pet/src/main.c:30:7: error: use of undeclared identifier 'Pet_species_other_c'; did you mean '_Pet_species_other'?
        case Pet_species_other_c:
             ^~~~~~~~~~~~~~~~~~~
             _Pet_species_other
/zcbor/samples/pet/include/pet_types.h:39:3: note: '_Pet_species_other' declared here
                _Pet_species_other = 3,
                ^
/zcbor/samples/pet/src/main.c:67:46: warning: passing 'const uint8_t[8]' (aka 'const unsigned char[8]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
        r = r && zcbor_bstr_put_arr(encoding_state, timestamp2);
                                                    ^~~~~~~~~~
[redacted]/lib/zcbor/include/zcbor_encode.h:107:31: note: expanded from macro 'zcbor_bstr_put_arr'
        zcbor_bstr_encode_ptr(state, string, sizeof(string))
                                     ^~~~~~
[redacted]/lib/zcbor/include/zcbor_encode.h:65:76: note: passing argument to parameter 'ptr' here
static inline bool zcbor_bstr_encode_ptr(zcbor_state_t *state, const char *ptr, size_t len)
                                                                           ^
/zcbor/samples/pet/src/main.c:104:31: error: use of undeclared identifier 'Pet_species_other_c'; did you mean '_Pet_species_other'?
        encoded_pet.species_choice = Pet_species_other_c;
                                     ^~~~~~~~~~~~~~~~~~~
                                     _Pet_species_other
/zcbor/samples/pet/include/pet_types.h:39:3: note: '_Pet_species_other' declared here
                _Pet_species_other = 3,
                ^
/zcbor/samples/pet/src/main.c:123:1: warning: return type of 'main' is not 'int' [-Wmain-return-type]
void main(void)
^
/zcbor/samples/pet/src/main.c:123:1: note: change return type to 'int'
void main(void)
^~~~
int
2 warnings and 4 errors generated.
make[2]: *** [CMakeFiles/app.dir/src/main.c.o] Error 1
make[1]: *** [CMakeFiles/app.dir/all] Error 2
make: *** [all] Error 2
oyvindronningstad commented 11 months ago

My guess is that you have zcbor installed via pip, and the pet main file is not compatible with the naming it generates. If you want to use the repo version of zcbor you can do python3 setup.py develop in the top-level.