BartVandewoestyne / Design-Patterns-GoF

Working code for the Design Patterns book from the Gang of Four.
278 stars 123 forks source link

GlyphFactory.cpp:20:22: error: array subscript has type 'char' [-Werror=char-subscripts] #2

Open franz-ms-muc opened 2 years ago

franz-ms-muc commented 2 years ago

GlyphFactory.cpp:20:22: error: array subscript has type 'char' [-Werror=char-subscripts]

char is signed on some machines. 

a Subscript of an Array is defined unsigned in C (0....n)

franz-ms-muc commented 2 years ago

https://github.com/Meisterschulen-am-Ostbahnhof-Munchen/Design-Patterns-GoF-on-ESP32/blob/feature/1/Structural_Patterns/Flyweight/components/Flyweight_component/GlyphFactory.cpp

here i will correct it so it runs in ESP32. please Double check it before take over to your Repo, because i do not check if it is running on PC !

franz-ms-muc commented 2 years ago

same Story for the delete[]. there is no new[]. so delete[] is wrong. 

https://stackoverflow.com/questions/2425728/delete-vs-delete-operators-in-c

BartVandewoestyne commented 7 months ago

same Story for the delete[]. there is no new[]. so delete[] is wrong. 

https://stackoverflow.com/questions/2425728/delete-vs-delete-operators-in-c

Thanks. I fixed the GlyphFactory destructor in commit d2641d8.

BartVandewoestyne commented 7 months ago

GlyphFactory.cpp:20:22: error: array subscript has type 'char' [-Werror=char-subscripts]

char is signed on some machines. 

a Subscript of an Array is defined unsigned in C (0....n)

I agree that there is an issue with the code and that this warning is justifiable. However, this is how the code in the book is. I am thinking of keeping the book's code in the master branch and then creating an extra branch for all the bugfixes to the book's code. Doing a diff between the master branch and that branch would then show where the book's code had some issues...