Hi list,
I've run into an unexpected problem which I can't figure out how to solve
properly. It seems to me to be impossible to typedef an "nx" (external)
type to a new name for some strange reason. I can't find anything in the
documentation that mentions this as a limitation, so I'm posting here in
hope of some enlightenment.
If I try to build an app with a function taking a typedef'd nx type as an
argument, I get this error:
$ make micaz
mkdir -p build/micaz
compiling TestNxTypedefC to a micaz binary
ncc -o build/micaz/main.exe -Os -fnesc-separator=__ -Wall -Wshadow
-Wnesc-all -target=micaz -fnesc-cfile=build/micaz/app.c -board=micasb
-DDEFINED_TOS_AM_GROUP=0x22 --param max-inline-insns-single=100000
-DIDENT_APPNAME=\"TestNxTypedefC\" -DIDENT_USERNAME=\"johny\"
-DIDENT_HOSTNAME=\"silence\" -DIDENT_USERHASH=0x4027b159L
-DIDENT_TIMESTAMP=0x5118d006L -DIDENT_UIDHASH=0x666c09d5L
-fnesc-dump=wiring -fnesc-dump='interfaces(!abstract())'
-fnesc-dump='referenced(interfacedefs, components)'
-fnesc-dumpfile=build/micaz/wiring-check.xml TestNxTypedefC.nc -lm
TestNxTypedefP.nc:14:85: error: expected ‘)’ before ‘val’
TestNxTypedefP.nc:14:85: error: expected ‘)’ before ‘val’
TestNxTypedefP.nc: In function ‘TestNxTypedefP__Init__init’:
TestNxTypedefP.nc:21:3: warning: implicit declaration of function
‘TestNxTypedefP__foo’
make: *** [exe0] Error 1
Yet, if I simply change the typedef to a #define instead, the app compiles
without even a warning. I thought it might be because I hadn't updated my
toolchain (I was still using hinrg repo), but even after switching to
tinyprod I get the same error.
Minimal test app as follows:
==== Makefile ====
COMPONENT=TestNxTypedefC
include $(MAKERULES)
==== TestNxTypedefC ====
configuration TestNxTypedefC
{
}
implementation
{
components TestNxTypedefP, MainC;
MainC.SoftwareInit -> TestNxTypedefP;
}
==== TestNxTypedefP ====
module TestNxTypedefP
{
provides interface Init;
}
implementation
{
#if 1
/* This fails - why? */
typedef nx_uint16_t my_type16_t;
#else
/* This works, ugly though it is */
#define my_type16_t nx_uint16_t
#endif
error_t foo (my_type16_t val)
{
return (val == 1234) ? SUCCESS : FAIL;
}
command error_t Init.init (void)
{
return foo (1234);
}
}
First encountered with this toolchain:
$ ncc --version
ncc: 1.2.4
nescc: 1.3.1
gcc: gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Still encountered with this toolchain:
$ ncc --version
ncc: 1.4.2
nescc: 1.3.4
gcc: gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Thanks in advance,
/Johny*
*
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help