RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

native: OSX: example rpl_udp fails to build

Open thomaseichinger opened this issue 12 years ago • 13 comments

for OS X the rpl_udp example fails to build:

sc_net_if.c:56:5: error: conflicting types for 'isnumber'
int isnumber(char *str)
    ^
/usr/include/ctype.h:323:1: note: previous definition is here
isnumber(int _c)

When renaming to is_number it fails with

RIOT/sys/net/include/net_help.h:33:9: warning:
      'NTOHL' macro redefined
#define NTOHL HTONL
        ^
/usr/include/sys/_endian.h:133:9: note: previous definition is here
#define NTOHL(x)        (x) = ntohl((__uint32_t)x)
        ^
4 warnings generated.
net_if.c:433:28: error: expression is not assignable
        eui64->uint32[0] = HTONL(0x000000ff);
                           ^~~~~~~~~~~~~~~~~
/usr/include/sys/_endian.h:135:22: note: expanded from macro 'HTONL'
#define HTONL(x)        (x) = htonl((__uint32_t)x)
                        ~~~ ^
net_if.c:434:28: error: expression is not assignable
        eui64->uint16[2] = HTONS(0xfe00);
                           ^~~~~~~~~~~~~
/usr/include/sys/_endian.h:136:22: note: expanded from macro 'HTONS'
#define HTONS(x)        (x) = htons((__uint16_t)x)
                        ~~~ ^
2 errors generated.

And it nags a lot about deprecated getcontext, swapcontext and makecontext.

Building with

Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

thomaseichinger avatar May 14 '14 09:05 thomaseichinger

*context whining is in order.

LudwigKnuepfer avatar May 14 '14 09:05 LudwigKnuepfer

Got the same issues here ;)

emmanuelsearch avatar May 14 '14 09:05 emmanuelsearch

working on it

LudwigKnuepfer avatar May 14 '14 09:05 LudwigKnuepfer

@thomaseichinger is there a way to use a proper gcc on OSX?

LudwigKnuepfer avatar May 14 '14 10:05 LudwigKnuepfer

(gcc is just another name for clang on the test machine)

LudwigKnuepfer avatar May 14 '14 10:05 LudwigKnuepfer

yes, by installing it separately with package management tools like homebrew or macports and so on and then explicitly calling it with gcc-4.*.

thomaseichinger avatar May 14 '14 10:05 thomaseichinger

Mhk .. I guess clang support is needed anyways though..

LudwigKnuepfer avatar May 14 '14 10:05 LudwigKnuepfer

related: https://github.com/RIOT-OS/RIOT/pull/1166

LudwigKnuepfer avatar May 14 '14 12:05 LudwigKnuepfer

This proves very difficult (for me). Even force feeding the proper include to clang only results in an error:

Compiling.... helper.c

clang -include /Users/ludwig/native/RIOT/sys/net/include/net_help.h -DBOARD_NATIVE -DCPU_NATIVE -DMODULE_AUTO_INIT -DMODULE_CORE -DMODULE_CPU -DMODULE_DEFAULTTRANSCEIVER -DMODULE_DESTINY -DMODULE_IEEE802154 -D
MODULE_LIB -DMODULE_NATIVENET -DMODULE_NET_HELP -DMODULE_NET_IF -DMODULE_POSIX -DMODULE_PS -DMODULE_ROUTING -DMODULE_RPL -DMODULE_SHELL -DMODULE_SHELL_COMMANDS -DMODULE_SIXLOWPAN -DMODULE_SYS -DMODULE_TIMEX -D
MODULE_TRANSCEIVER -DMODULE_UART0 -DMODULE_VTIMER -Wall -Wextra -pedantic -m32 -std=gnu99 -I/Users/ludwig/native/RIOT/core/include -I/Users/ludwig/native/RIOT/drivers/include -I/Users/ludwig/native/RIOT/sys/in
clude -nobuiltininc -I/Users/ludwig/native/RIOT/boards/native/include/ -I/Users/ludwig/native/RIOT/core/include/ -I/Users/ludwig/native/RIOT/drivers/include/ -I/Users/ludwig/native/RIOT/cpu/native/include -I/U
sers/ludwig/native/RIOT/sys/include -include /Users/ludwig/native/RIOT/sys/net/include/net_help.h -I/Users/ludwig/native/RIOT/sys/net/include -I/Users/ludwig/native/RIOT/drivers/cc110x -I/Users/ludwig/native/R
IOT/drivers/cc110x_ng/include -I/Users/ludwig/native/RIOT/sys/net/routing/rpl -I/Users/ludwig/native/RIOT/sys/posix/include -c helper.c -o /Users/ludwig/native/RIOT/examples/rpl_udp/bin/native/rpl_udp/helper.o
In file included from helper.c:25:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/ip.h:178:28: error: expression is not assignable
    ipv6_addr->uint32[0] = HTONL(0xfe800000);
                           ^~~~~~~~~~~~~~~~~
/usr/include/sys/_endian.h:135:22: note: expanded from macro 'HTONL'
#define HTONL(x)        (x) = htonl((__uint32_t)x)
                        ~~~ ^
In file included from helper.c:25:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/ip.h:242:28: error: expression is not assignable
    ipv6_addr->uint32[3] = HTONL(1);
                           ^~~~~~~~
/usr/include/sys/_endian.h:135:22: note: expanded from macro 'HTONL'
#define HTONL(x)        (x) = htonl((__uint32_t)x)
                        ~~~ ^
In file included from helper.c:25:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/ip.h:258:28: error: expression is not assignable
    ipv6_addr->uint32[0] = HTONL(0xff020000);
                           ^~~~~~~~~~~~~~~~~
/usr/include/sys/_endian.h:135:22: note: expanded from macro 'HTONL'
#define HTONL(x)        (x) = htonl((__uint32_t)x)
                        ~~~ ^
In file included from helper.c:25:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/ip.h:261:28: error: expression is not assignable
    ipv6_addr->uint32[3] = HTONL(2);
                           ^~~~~~~~
/usr/include/sys/_endian.h:135:22: note: expanded from macro 'HTONL'
#define HTONL(x)        (x) = htonl((__uint32_t)x)
                        ~~~ ^
In file included from helper.c:25:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/ip.h:277:28: error: expression is not assignable
    ipv6_addr->uint32[0] = HTONL(0xff020000);
                           ^~~~~~~~~~~~~~~~~
/usr/include/sys/_endian.h:135:22: note: expanded from macro 'HTONL'
#define HTONL(x)        (x) = htonl((__uint32_t)x)
                        ~~~ ^
In file included from helper.c:25:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/ip.h:280:28: error: expression is not assignable
    ipv6_addr->uint32[3] = HTONL(1);
                           ^~~~~~~~
/usr/include/sys/_endian.h:135:22: note: expanded from macro 'HTONL'
#define HTONL(x)        (x) = htonl((__uint32_t)x)
                        ~~~ ^
In file included from helper.c:25:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/ip.h:300:32: error: expression is not assignable
    ipv6_addr_out->uint32[0] = HTONL(0xff020000);
                               ^~~~~~~~~~~~~~~~~
/usr/include/sys/_endian.h:135:22: note: expanded from macro 'HTONL'
#define HTONL(x)        (x) = htonl((__uint32_t)x)
                        ~~~ ^
In file included from helper.c:25:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/ip.h:302:32: error: expression is not assignable
    ipv6_addr_out->uint32[2] = HTONS(1);
                               ^~~~~~~~
/usr/include/sys/_endian.h:136:22: note: expanded from macro 'HTONS'
#define HTONS(x)        (x) = htons((__uint16_t)x)
                        ~~~ ^
In file included from helper.c:25:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/ip.h:392:12: error: expression is not assignable
           NTOHL(ipv6_addr->uint32[3]) == 1;
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/_endian.h:133:22: note: expanded from macro 'NTOHL'
#define NTOHL(x)        (x) = ntohl((__uint32_t)x)
                            ^
In file included from helper.c:25:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/ip.h:408:38: error: expression is not assignable
    return ((ipv6_addr->uint32[0] == HTONL(0xfe800000)) &&
             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/sys/_endian.h:135:22: note: expanded from macro 'HTONL'
#define HTONL(x)        (x) = htonl((__uint32_t)x)
                            ^
In file included from helper.c:25:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/ip.h:445:37: error: expression is not assignable
    return (ipv6_addr->uint32[0] == HTONL(0xff020000)) &&
            ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/sys/_endian.h:135:22: note: expanded from macro 'HTONL'
#define HTONL(x)        (x) = htonl((__uint32_t)x)
                            ^
In file included from helper.c:25:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/ip.h:447:37: error: expression is not assignable
           (ipv6_addr->uint32[2] == HTONL(1)) &&
            ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/sys/_endian.h:135:22: note: expanded from macro 'HTONL'
#define HTONL(x)        (x) = htonl((__uint32_t)x)
                            ^
In file included from helper.c:28:
In file included from /Users/ludwig/native/RIOT/sys/net/routing/rpl/rpl_structs.h:19:
In file included from /Users/ludwig/native/RIOT/sys/net/include/ipv6.h:26:
In file included from /Users/ludwig/native/RIOT/sys/net/include/../network_layer/sixlowpan/icmp.h:30:
In file included from /Users/ludwig/native/RIOT/sys/net/include/../network_layer/sixlowpan/lowpan.h:31:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/lowpan.h:202:27: error: expression is not assignable
        iid->uint16[2] == HTONS(0xfe00)) {
        ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/sys/_endian.h:136:22: note: expanded from macro 'HTONS'
#define HTONS(x)        (x) = htons((__uint16_t)x)
                            ^
In file included from helper.c:28:
In file included from /Users/ludwig/native/RIOT/sys/net/routing/rpl/rpl_structs.h:19:
In file included from /Users/ludwig/native/RIOT/sys/net/include/ipv6.h:26:
In file included from /Users/ludwig/native/RIOT/sys/net/include/../network_layer/sixlowpan/icmp.h:30:
In file included from /Users/ludwig/native/RIOT/sys/net/include/../network_layer/sixlowpan/lowpan.h:31:
/Users/ludwig/native/RIOT/sys/net/include/sixlowpan/lowpan.h:203:16: error: read-only variable is not assignable
        return NTOHS(iid->uint16[3]);
               ^~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/_endian.h:134:22: note: expanded from macro 'NTOHS'
#define NTOHS(x)        (x) = ntohs((__uint16_t)x)
                        ~~~ ^
14 errors generated.
make: *** [/Users/ludwig/native/RIOT/examples/rpl_udp/bin/native/rpl_udp/helper.o] Error 1

LudwigKnuepfer avatar May 14 '14 13:05 LudwigKnuepfer

OK, I'm sick of OSX problems... on Linux this build with clang (3.4). If someone wants to fix it - go ahead.

LudwigKnuepfer avatar May 14 '14 13:05 LudwigKnuepfer

@LudwigOrtmann I hacked something in https://github.com/thomaseichinger/RIOT/tree/fix_rpl_udp_osx. in sys/net/include/net_help.h

+#ifdef __MACH__
+#undef HTONS
+#undef HTONL
+#undef HTONLL
+#undef NTOHS
+#undef NTOHL
+#undef NTOHLL
+#endif

#define BITSET(var,pos) ((var) & (1<<(pos)))
#define HTONS(a) ((((uint16_t) (a) >> 8) & 0xff) | ((((uint16_t) (a)) & 0xff) << 8))
#define HTONL(a) ((((uint32_t) (a) & 0xff000000) >> 24) | \
                  (((uint32_t) (a) & 0x00ff0000) >> 8)  | \
                  (((uint32_t) (a) & 0x0000ff00) << 8)  | \
                  (((uint32_t) (a) & 0x000000ff) << 24))
#define HTONLL(a) ((((uint64_t) (a) & 0xff00000000000000) >> 56) | \
                   (((uint64_t) (a) & 0x00ff000000000000) >> 40)  | \
                   (((uint64_t) (a) & 0x0000ff0000000000) >> 24) | \
                   (((uint64_t) (a) & 0x000000ff00000000) >> 8)  | \
                   (((uint64_t) (a) & 0x00000000ff000000) << 8)  | \
                   (((uint64_t) (a) & 0x0000000000ff0000) << 24)  | \
                   (((uint64_t) (a) & 0x000000000000ff00) << 40)  | \
                   (((uint64_t) (a) & 0x00000000000000ff) << 56))
#define NTOHS HTONS
#define NTOHL HTONL
#define NTOHLL HTONLL

and reordered header includes in the files needed.

Worth a PR or too ugly?

thomaseichinger avatar May 14 '14 14:05 thomaseichinger

You can also pass these undefs to clang directly - that would be less ugly...

LudwigKnuepfer avatar May 14 '14 14:05 LudwigKnuepfer

... if it works

LudwigKnuepfer avatar May 14 '14 14:05 LudwigKnuepfer