richard_damon wrote on Friday, March 05, 2010:
The problem is that FreeRTOS hides the definitions of its structures in the c files, for data hiding. A way to fix this and allow selected user files to be able to see the structure information, while still keeping the hiding for most user files, would be to move the structure definition to the header files, but use a preprocessor definition to control whether the structure is defined with details or opaquely. The FreeRTOS files would define this definition, and any use file that for debugging needed it could define it, but the reset get the void* typedef.
I do something like this in the version I use. To help with updating, I didn’t remove the definition from the c files, just bracketed it with #if 0 and #endif, that way when I diff the current code with the old, I can detect any changes in the data structures and move the changes over. Perhaps I should clean up how I do this and submit it to Richard as a suggested improvement.
I understand that the current method being used grew out of a need to support a number of somewhat broken C compilers (the embedded market is know for this problem, many chips with smaller market share don’t generate enough interest for the manufactures to get a fully working compiler up, so they often don’t support the full language). Technically, the technique used invokes undefined behavior, since the prototype used by the user code passes void* pointers, but the functions are declared with struct* pointers, which are not guaranteed by the language to look the same, but for practical purposes will be as long as the machine is inherently “byte addressable”, which all the target processors are.