contiki-os / contiki

The official git repository for Contiki, the open source OS for the Internet of Things
http://www.contiki-os.org/
Other
3.71k stars 2.58k forks source link

CoAP do not compile with SDCC (8051 MCU) #619

Closed cquijano closed 10 years ago

cquijano commented 10 years ago

CoAP do not compile with lastest versions of SDCC and Contiki: Contiki Version:

commit 429024f0a17714da3a81678076117e17f30a57a9

SDCC Version(Compiled as tutorial: https://github.com/contiki-os/contiki/wiki/8051-Requirements):

SDCC : mcs51/r3ka/tlcs90/s08/stm8 3.4.0 #8964 (Mar 27 2014) (Linux)
published under GNU General Public License (GPL)
carlos@Sirio:~/src/zigbee/senso/contiki/examples/er-rest-example$ make TARGET=cc2530dk
INFO: compiling with CoAP-13
mkdir obj_cc2530dk
cat     ../../platform/cc2530dk/./segment.rules      ../../cpu/cc253x/./segment.rules              | \
           sed -e 's/#.*$//' -e 's/^\s*//' -e '/^$/d' > obj_cc2530dk/segment.rules
  CC        ../../apps/er-coap-13/er-coap-13.c
../../apps/er-coap-13/er-coap-13.c:125: syntax error: token -> 'unsigned' ; column 10
../../apps/er-coap-13/er-coap-13.c:128: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:128: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:130: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:130: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:130: error 43: invalid operand for shift operator
../../apps/er-coap-13/er-coap-13.c:130: warning 113: left & right types are 
void,const-unsigned-char literal
../../apps/er-coap-13/er-coap-13.c:131: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:131: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:131: error 47: indirections to different types assignment   
from type 'void'
  to type 'unsigned-char fixed'
../../apps/er-coap-13/er-coap-13.c:133: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:133: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:135: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:135: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:135: error 47: indirections to different types assignment   
from type 'void'
  to type 'unsigned-char fixed'
../../apps/er-coap-13/er-coap-13.c:138: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:138: error 44: compare operand cannot be struct/union
comparing type int fixed to type unsigned-int near* auto
../../apps/er-coap-13/er-coap-13.c:138: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:138: error 47: indirections to different types assignment   
from type 'unsigned-int near* auto'
  to type 'int fixed'
../../apps/er-coap-13/er-coap-13.c:183: warning 185: comparison of 'signed char' with 'unsigned char' requires promotion to int
../../apps/er-coap-13/er-coap-13.c:181: warning 94: comparison is always false due to limited range of data type
../../apps/er-coap-13/er-coap-13.c:360: syntax error: token -> 'uint32_t' ; column 127
../../apps/er-coap-13/er-coap-13.c:361: syntax error: token -> 'uint32_t' ; column 127
../../apps/er-coap-13/er-coap-13.c:360: error 20: Undefined identifier 'block'
../../apps/er-coap-13/er-coap-13.c:360: error 20: Undefined identifier 'block'
../../apps/er-coap-13/er-coap-13.c:360: error 20: Undefined identifier 'block'
../../apps/er-coap-13/er-coap-13.c:360: error 20: Undefined identifier 'block'
../../apps/er-coap-13/er-coap-13.c:360: error 20: Undefined identifier 'block'
../../apps/er-coap-13/er-coap-13.c:360: error 20: Undefined identifier 'block'
../../apps/er-coap-13/er-coap-13.c:361: error 20: Undefined identifier 'block'
../../apps/er-coap-13/er-coap-13.c:361: error 20: Undefined identifier 'block'
../../apps/er-coap-13/er-coap-13.c:361: error 20: Undefined identifier 'block'
../../apps/er-coap-13/er-coap-13.c:361: error 20: Undefined identifier 'block'
../../apps/er-coap-13/er-coap-13.c:361: error 20: Undefined identifier 'block'
../../apps/er-coap-13/er-coap-13.c:361: error 20: Undefined identifier 'block'
../../apps/er-coap-13/er-coap-13.c:442: syntax error: token -> 'uint8_t' ; column 9
../../apps/er-coap-13/er-coap-13.c:461: syntax error: token -> 'unsigned' ; column 10
../../apps/er-coap-13/er-coap-13.c:490: syntax error: token -> 'unsigned' ; column 12
../../apps/er-coap-13/er-coap-13.c:444: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:444: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:444: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'const-void generic* fixed'
../../apps/er-coap-13/er-coap-13.c:459: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:459: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:465: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:465: error 44: compare operand cannot be struct/union
comparing type int fixed to type unsigned-char generic* auto
../../apps/er-coap-13/er-coap-13.c:468: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:468: error 22: Array or pointer required for '[]' operation 
../../apps/er-coap-13/er-coap-13.c:468: error 44: compare operand cannot be struct/union
comparing type void to type const-unsigned-char literal
../../apps/er-coap-13/er-coap-13.c:470: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:485: error 20: Undefined identifier 'option_delta'
../../apps/er-coap-13/er-coap-13.c:485: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:485: error 22: Array or pointer required for '[]' operation 
../../apps/er-coap-13/er-coap-13.c:485: error 47: indirections to different types assignment   
from type 'void'
  to type 'int fixed'
../../apps/er-coap-13/er-coap-13.c:486: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:486: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:486: error 22: Array or pointer required for '[]' operation 
../../apps/er-coap-13/er-coap-13.c:486: error 47: indirections to different types assignment   
from type 'void'
  to type 'int fixed'
../../apps/er-coap-13/er-coap-13.c:487: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:493: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:493: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:495: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:495: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:495: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:495: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:495: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:495: error 22: Array or pointer required for '[]' operation 
../../apps/er-coap-13/er-coap-13.c:496: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:498: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:498: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:500: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:500: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:500: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:500: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:501: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:501: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:501: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:501: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:501: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:501: error 22: Array or pointer required for '[]' operation 
../../apps/er-coap-13/er-coap-13.c:502: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:503: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:503: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:503: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:503: error 27: Pointer required
../../apps/er-coap-13/er-coap-13.c:503: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:503: error 22: Array or pointer required for '[]' operation 
../../apps/er-coap-13/er-coap-13.c:504: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:507: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:507: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:507: error 44: compare operand cannot be struct/union
comparing type int fixed to type int near* fixed
../../apps/er-coap-13/er-coap-13.c:507: error 20: Undefined identifier 'x'
../../apps/er-coap-13/er-coap-13.c:507: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:507: error 47: indirections to different types assignment   
from type 'int near* fixed'
  to type 'int fixed'
../../apps/er-coap-13/er-coap-13.c:509: error 20: Undefined identifier 'option_number'
../../apps/er-coap-13/er-coap-13.c:509: error 20: Undefined identifier 'option_number'
../../apps/er-coap-13/er-coap-13.c:509: error 20: Undefined identifier 'option_delta'
../../apps/er-coap-13/er-coap-13.c:513: error 20: Undefined identifier 'option_number'
../../apps/er-coap-13/er-coap-13.c:513: error 20: Undefined identifier 'option_number'
../../apps/er-coap-13/er-coap-13.c:513: error 20: Undefined identifier 'option_number'
../../apps/er-coap-13/er-coap-13.c:515: error 20: Undefined identifier 'option_number'
../../apps/er-coap-13/er-coap-13.c:518: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:518: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:518: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'unsigned-char generic* fixed'
../../apps/er-coap-13/er-coap-13.c:518: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:522: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:522: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:522: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'unsigned-char generic* fixed'
../../apps/er-coap-13/er-coap-13.c:522: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:526: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:526: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:527: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:527: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:527: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'const-void generic* fixed'
../../apps/er-coap-13/er-coap-13.c:542: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:542: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:542: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'unsigned-char generic* fixed'
../../apps/er-coap-13/er-coap-13.c:542: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:549: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:549: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:550: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:550: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:550: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'const-void generic* fixed'
../../apps/er-coap-13/er-coap-13.c:568: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:568: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'char generic* fixed'
../../apps/er-coap-13/er-coap-13.c:569: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:573: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:573: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:573: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'unsigned-char generic* fixed'
../../apps/er-coap-13/er-coap-13.c:573: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:578: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:578: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:578: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'unsigned-char generic* auto'
../../apps/er-coap-13/er-coap-13.c:578: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:583: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:583: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:583: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'unsigned-char generic* auto'
../../apps/er-coap-13/er-coap-13.c:583: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:589: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:589: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:589: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'unsigned-char generic* auto'
../../apps/er-coap-13/er-coap-13.c:589: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:594: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:594: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:594: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'unsigned-char generic* auto'
../../apps/er-coap-13/er-coap-13.c:594: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:600: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:600: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'char generic* fixed'
../../apps/er-coap-13/er-coap-13.c:601: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:609: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:609: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:609: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'unsigned-char generic* fixed'
../../apps/er-coap-13/er-coap-13.c:609: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:613: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:613: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:613: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'unsigned-char generic* fixed'
../../apps/er-coap-13/er-coap-13.c:613: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:621: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:621: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:621: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'unsigned-char generic* fixed'
../../apps/er-coap-13/er-coap-13.c:621: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:629: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:629: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:629: warning 127: non-pointer type cast to generic pointer
from type 'int fixed'
  to type 'unsigned-char generic* fixed'
../../apps/er-coap-13/er-coap-13.c:629: error 20: Undefined identifier 'option_length'
../../apps/er-coap-13/er-coap-13.c:635: error 20: Undefined identifier 'option_number'
../../apps/er-coap-13/er-coap-13.c:642: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:642: error 20: Undefined identifier 'current_option'
../../apps/er-coap-13/er-coap-13.c:642: error 20: Undefined identifier 'option_length'
make: *** [obj_cc2530dk/er-coap-13.rel] Error 1

Thanks in advance.

g-oikonomou commented 10 years ago

That's a case of variable declarations intermingled with code: SDCC will refuse to compile that. For instance:

static
size_t
coap_set_option_header(unsigned int delta, size_t length, uint8_t *buffer)
{
  size_t written = 0;

  buffer[0] = coap_option_nibble(delta)<<4 | coap_option_nibble(length);

  /* avoids code duplication without function overhead */
  unsigned int *x = &delta;

Here, the declaration of *x follows a statement.

I've tried in the past to patch coap to make it build with SDCC but I vaguely remember stumbling across a different error which I didn't manage to figure out. Even if you do make it compile, I can suspect you'd run into stack overflow problems.

louizaidres commented 10 years ago

Hello I am a master student, I need to use the simulator cooja in contiki, I tried to simulate the examples coap-client-server-example.csc works well but applying make connect-router-cooja Refused connection If you guided me to do or to give me information if so thank you for your reading. cordially

2014-04-02 23:53 GMT+02:00 George Oikonomou notifications@github.com:

That's a case of variable declarations intermingled with code: SDCC will refuse to compile that. For instance:

static size_t coap_set_option_header(unsigned int delta, size_t length, uint8_t *buffer) { size_t written = 0;

buffer[0] = coap_option_nibble(delta)<<4 | coap_option_nibble(length);

/* avoids code duplication without function overhead / unsigned int x = δ

Here, the declaration of *x follows a statement.

I've tried in the past to patch coap to make it build with SDCC but I vaguely remember stumbling across a different error which I didn't manage to figure out. Even if you do make it compile, I can suspect you'd run into stack overflow problems.

Reply to this email directly or view it on GitHubhttps://github.com/contiki-os/contiki/issues/619#issuecomment-39388758 .

cquijano commented 10 years ago

I wrote some changes to make it compile with (debuggin propouses, do not merge):

https://github.com/cquijano/contiki/tree/coap_sdcc

g-oikonomou commented 10 years ago

@cquijano I had a quick look at your branch and this is probably a good step forward.

I'm going to close this issue as a "question which was answered". If you manage to make things play nicely with 8051-based hardware, a pull request would be great.

Thanks!