chipKIT® Development Platform

Inspired by Arduino™

Error reported when using typedef pointer

Created Sun, 25 Dec 2011 08:43:01 +0000 by fiddler


fiddler

Sun, 25 Dec 2011 08:43:01 +0000

I'm trying to get Protothread running on a MAX32 board. I get the following error when compiling the code

In file included from Proto_V3.cpp:5:
/home/kim/MP_IDE/M/mpide-0022-linux32-20110822/./libraries/Protothread/lc-addrlabels.h:62: error: conflicting declaration ‘typedef void* lc_t’
/home/kim/MP_IDE/M/mpide-0022-linux32-20110822/./libraries/Protothread/lc-switch.h:64: error: ‘lc_t’ has a previous declaration as ‘typedef short unsigned int lc_t’
Proto_V3.cpp: In function ‘int protothread1(pt*, int)’:
pt_led_example:38: error: invalid conversion from ‘void*’ to ‘lc_t’
Proto_V3.cpp: In function ‘int protothread2(pt*, int)’:
pt_led_example:49: error: invalid conversion from ‘void*’ to ‘lc_t’

In one header file I have:

typedef void * lc_t;

and in another header file I have:

typedef unsigned short lc_t;

My C skills are pretty weak, so I need some directions here.

Why is there a conflict ?

Download available here: [url]http://code.google.com/p/arduinode/downloads/detail?name=pt.zip[/url]


majenko

Sun, 25 Dec 2011 10:52:26 +0000

My god, that's a cryptic bit of code.

My C skillz are not so weak, but I still don't get what's going on there.

Things I don't understand:

  1. the "lc" variable doesn't seem to actually be used anywhere

  2. Yes, there are two definitions of the lc_t type - the one in the lc-addrlabels.h doesn't seem to ever be used.

  3. What's with all the \hideinitializer, \defgroup, \code and stuff like that scattered around everywhere?

  4. This looks to me to just be header files - where is the code? Don't tell me it's all in the header files - do these muppets not know how to write a C++ file?

I need a shower now - I feel dirty.


fiddler

Sun, 25 Dec 2011 17:56:35 +0000

Haha. I was reading up on pointers last night but still not much wiser with regards to this Also downloaded the latest mpide, so something might change.

It compiles fine when selecting a Duemilanova board, so I guess it might have something to do with the difference between C and C++ and their handling of Typedef. I presume that the 8bit chips are only using C and the 32bit chips are using a C++ wrapper in GCC ??

I only started using C last week, so I got a steep learning curve in front of me, though i do understand assembly.

Bugger, I got to go to work, this would have been much more fun to play with :-)


fiddler

Tue, 27 Dec 2011 00:58:57 +0000

Okay, I got it to compile and run :-), but only on 32bit board selection now.

Deleted all the previous directories and installed the latest version 23. Modified the preference.txt to ensure the path was correct (which it wasn't) in both the .mpide and .arduino directories.

Copied the Protothread header files in every subdirectory under mpide and viola, we got liftoff.