ludocode / mpack

MPack - A C encoder/decoder for the MessagePack serialization format / msgpack.org[C]
MIT License
533 stars 82 forks source link

Compile warnings with -Wmissing-prototypes #20

Closed xor-gate closed 9 years ago

xor-gate commented 9 years ago

I'm trying to compile with strict compiler flags and it seems to emit warnings (which are valid):

i'm using the v0.6 amalgamated package

/home/jjacobs/repos/dinet/libdi/include/mpack/mpack.h:387:31: error: no previous prototype for ‘mpack_realloc’ [-Werror=missing-prototypes]
     MPACK_ALWAYS_INLINE void* mpack_realloc(void* old_ptr, size_t used_size, size_t new_size) {
                               ^
/home/jjacobs/repos/dinet/libdi/include/mpack/mpack.h:569:26: error: no previous prototype for ‘mpack_tag_nil’ [-Werror=missing-prototypes]
 MPACK_INLINE mpack_tag_t mpack_tag_nil(void) {
                          ^
/home/jjacobs/repos/dinet/libdi/include/mpack/mpack.h:577:26: error: no previous prototype for ‘mpack_tag_int’ [-Werror=missing-prototypes]
 MPACK_INLINE mpack_tag_t mpack_tag_int(int64_t value) {
                          ^
/home/jjacobs/repos/dinet/libdi/include/mpack/mpack.h:586:26: error: no previous prototype for ‘mpack_tag_uint’ [-Werror=missing-prototypes]
 MPACK_INLINE mpack_tag_t mpack_tag_uint(uint64_t value) {
                          ^
/home/jjacobs/repos/dinet/libdi/include/mpack/mpack.h:595:26: error: no previous prototype for ‘mpack_tag_bool’ [-Werror=missing-prototypes]
 MPACK_INLINE mpack_tag_t mpack_tag_bool(bool value) {
                          ^
/home/jjacobs/repos/dinet/libdi/include/mpack/mpack.h:604:26: error: no previous prototype for ‘mpack_tag_float’ [-Werror=missing-prototypes]
 MPACK_INLINE mpack_tag_t mpack_tag_float(float value) {
                          ^
/home/jjacobs/repos/dinet/libdi/include/mpack/mpack.h:613:26: error: no previous prototype for ‘mpack_tag_double’ [-Werror=missing-prototypes]
 MPACK_INLINE mpack_tag_t mpack_tag_double(double value) {
                          ^
/home/jjacobs/repos/dinet/libdi/include/mpack/mpack.h:648:19: error: no previous prototype for ‘mpack_tag_equal’ [-Werror=missing-prototypes]
 MPACK_INLINE bool mpack_tag_equal(mpack_tag_t left, mpack_tag_t right) {
                   ^
/home/jjacobs/repos/dinet/libdi/include/mpack/mpack.h:662:29: error: no previous prototype for ‘mpack_load_native_u8’ [-Werror=missing-prototypes]
 MPACK_ALWAYS_INLINE uint8_t mpack_load_native_u8(const char* p) {
                             ^
/home/jjacobs/repos/dinet/libdi/include/mpack/mpack.h:666:30: error: no previous prototype for ‘mpack_load_native_u16’ [-Werror=missing-prototypes]
 MPACK_ALWAYS_INLINE uint16_t mpack_load_native_u16(const char* p) {

etcetera...
ludocode commented 9 years ago

This appears to be happening due to the following GCC bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877

These are fixed as of GCC 5.1. For older versions I'll probably need to add a compiler pragma to ignore these warnings (since I really don't want to have to forward-declare inlines.)

ludocode commented 9 years ago

This is now fixed on develop. Turns out there were a few other issues with supporting -Wmissing-prototypes, so those are fixed, and the warning is ignored in header files on GCC versions 4.6 through 4.9.

xor-gate commented 9 years ago

Very nice! This is very good for people (like me) who use embedded toolchains which are not higher than version 4.9.

Thanks for your effort!