Skip to content

Commit

Permalink
cmake/config_posix Add missing Feature test Macro
Browse files Browse the repository at this point in the history
From man be32toh:

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       htobe16(),  htole16(),  be16toh(),  le16toh(),  htobe32(),  htole32(),  be32toh(),   le32toh(),
       htobe64(), htole64(), be64toh(), le64toh():
           Since glibc 2.19:
               _DEFAULT_SOURCE
           In glibc up to and including 2.19:
               _BSD_SOURCE

Fixes build error:

[ 59%] Building C object examples/CMakeFiles/felica-read-ndef.dir/felica-read-ndef.c.o
/tmp/libfreefare/examples/felica-read-ndef.c: In function ‘main’:
/tmp/libfreefare/examples/felica-read-ndef.c:113:21: warning: implicit declaration of function ‘be32toh’ [-Wimplicit-function-declaration]
    payload_length = be32toh(*(uint32_t *)(ndef_record + 2));
                     ^~~~~~~
[ 61%] Linking C executable felica-read-ndef
/usr/bin/ld: CMakeFiles/felica-read-ndef.dir/felica-read-ndef.c.o: in function `main':
felica-read-ndef.c:(.text+0x319): undefined reference to `be32toh'
collect2: error: ld returned 1 exit status

Signed-off-by: Ricardo Ribalda Delgado <[email protected]>
  • Loading branch information
ribalda committed Sep 18, 2018
1 parent 081e7f9 commit 5e51f7f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmake/config_posix.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
#cmakedefine HAVE_BYTESWAP_H @_HAVE_BYTESWAP_H@
#cmakedefine HAVE_COREFOUNDATION_COREFOUNDATION_H @_HAVE_COREFOUNDATION_COREFOUNDATION_H@

#ifdef HAVE_ENDIAN_H
#define _DEFAULT_SOURCE
#endif

#endif /* !__CONFIG_POSIX_H__ */

0 comments on commit 5e51f7f

Please sign in to comment.