TInyOS 1.x Генерация ошибки при компиляции BLINK - PullRequest
0 голосов
/ 28 февраля 2010

root @ everton-laptop: /opt/tinyos-1.x/apps/Blink# make pc

compiling Blink to a pc binary

ncc -o build/pc/main.exe -g -O0 -board=micasb -pthread -target=pc  -Wall -Wshadow    -DDEF_TOS_AM_GROUP=0x7d -Wnesc-all -fnesc-nido-tosnodes=1000 -fnesc-cfile=build/pc/app.c Blink.nc -lm 

In file included from /opt/tinyos-1.x/tos/platform/pc/packet_sim.h:55,
                 from /opt/tinyos-1.x/tos/platform/pc/nido.h:81,
                 from /opt/tinyos-1.x/tos/platform/pc/hardware.h:43,
                 from /opt/tinyos-1.x/tos/system/tos.h:144:
/opt/tinyos-1.x/tos/types/AM.h:155: parse error before `struct'
/opt/tinyos-1.x/tos/types/AM.h:156: parse error before `struct'
/opt/tinyos-1.x/tos/types/AM.h:158: parse error before `struct'
/opt/tinyos-1.x/tos/types/AM.h: In function `TOS_MsgLength':
/opt/tinyos-1.x/tos/types/AM.h:186: parse error before `TOS_Msg'
In file included from /opt/tinyos-1.x/tos/platform/pc/hardware.h:116,
                 from /opt/tinyos-1.x/tos/system/tos.h:144:
/opt/tinyos-1.x/tos/platform/pc/eeprom.c: At top level:
/opt/tinyos-1.x/tos/platform/pc/eeprom.c:115: warning: declaration of `length' shadows global declaration
/opt/tinyos-1.x/tos/types/AM.h:158: warning: location of shadowed declaration
/opt/tinyos-1.x/tos/platform/pc/eeprom.c:145: warning: declaration of `length' shadows global declaration
/opt/tinyos-1.x/tos/types/AM.h:158: warning: location of shadowed declaration
make: *** [build/pc/main.exe] Error 1

Пробовал компилировать BLink, и я продолжаю получать вышеуказанную ошибку и не уверен, что делать дальше. любая помощь была бы хороша.

1 Ответ

1 голос
/ 28 февраля 2010

Глядя на репозиторий CVS для tos/types/AM.h, похоже, что он задыхается от следующего кода:

154: enum {
155:    MSG_DATA_SIZE = offsetof(struct TOS_Msg, crc) + sizeof(uint16_t), // 36 by default
156:    TINYSEC_MSG_DATA_SIZE = offsetof(struct TinySec_Msg, mac) + TINYSEC_MAC_LENGTH, // 41 by default
157:    DATA_LENGTH = TOSH_DATA_LENGTH,
158:    LENGTH_BYTE_NUMBER = offsetof(struct TOS_Msg, length) + 1,
159:    TINYSEC_NODE_ID_SIZE = sizeof(uint16_t)
160: };

Обычным элементом из строк 155, 156 и 158 является макрос offsetof(), который должен быть определен в stddef.h и который выглядит так, как будто должен был быть введен tos.h, прежде чем он вызовет AM.h быть включенным, поэтому offsetof() уже должно быть определено.

Возможно, вы захотите проверить, правильно ли используется используемый вами компилятор offsetof() и / или почему он не доступен для использования в AM.h. При необходимости вы, вероятно, можете определить его самостоятельно, используя более или менее обычную реализацию:

#define offsetof(st, m) ((size_t) ( (char *)&((st *)(0))->m - (char *)0 ))  // stolen from Wikipedia
...