Compiler warnings

Hi I consider it good practice to have the warning level set to maximum I always get the following warnings: C:devFreeRTOSSourcelist.c:64:Warning [2066] type qualifier mismatch in assignment C:devFreeRTOSSourcelist.c:72:Warning [2066] type qualifier mismatch in assignment C:devFreeRTOSSourcelist.c:73:Warning [2066] type qualifier mismatch in assignment C:devFreeRTOSSourcelist.c:130:Warning [2066] type qualifier mismatch in assignment These are cause by a missing ‘volatile’ in the casting. The target variables of the assignments on these lines are volatile xListItem *, but the applied casting is only (xListItem *) This should be (volatile xListItem *) I also get C:devFreeRTOSSourcetasks.c:461:Warning [2066] type qualifier mismatch in assignment Which also need a volatile prefix: pxTopOfStack is defined (volatile portSTACK_TYPE *), but a (portSTACK_TYPE *) is assigned to it. That should be (volatile portSTACK_TYPE *) This should be the same on all platforms (not only C18 which I use) since list.c and tasks.c are shared among all platforms. Paul

Compiler warnings

> The target variables of the assignments on these lines are > volatile xListItem *, but the applied casting is only > (xListItem *) This should be (volatile xListItem *) In which case other compilers used to compile FreeRTOS.org will complain about "meaningless qualifier on cast".  Can’t win there I’m afraid. > I also get > C:devFreeRTOSSourcetasks.c:461:Warning [2066] type > qualifier mismatch in assignment Which also need a volatile prefix: > pxTopOfStack is defined (volatile portSTACK_TYPE *), but a > (portSTACK_TYPE *) is assigned to it. That should be > (volatile portSTACK_TYPE *) Likewise. > > This should be the same on all platforms …but it isn’t, unfortunately. The C18 compiler is not exactly standard in any case. Regards.

Compiler warnings

Of course I’m wrong, how could this have slipped other peoples attention? ;-(

Compiler warnings

I think Paul does have a valid point. The warning that Paul spoke of is a valid warning in my opinion, since the volatile qualifier in a cast may determine what sort of code the compiler generates. Perhaps not in this case since both sides of the assignment are volatile but strictly speaking the right hand side of the assignment is not the same type as the left side and if a programmer forgets a volatile qualifier elsewhere, such warnings may be overlooked, perhaps resulting in nasty hard-to-find bugs. The warning "meaningless qualifier on cast" is a warning that I consider as being meaningless in itself. Actually I think the warning is plainly wrong! Perhaps it was meaningless for that particular implementation of a C compiler but I think someone was being pedantic when they implemented that one. In other words, perhaps the volatile should be added in which case a more serious warning will be replaced by a less serious (and meaningless/wrong) one. gcc also issues warnings on the same four lines ("dereferencing type-punned pointer will break strict-aliasing rules")…

Compiler warnings

Another thought… The existing casts require that the members of xMiniListItem exactly overlap the first three members of xListItem but are there any guarantees that this is always the case with every compiler? Wouldn’t it be better to replace the xItemValue, pxNext and pxPrevious members of xListItem with a nested xMiniListItem? This would get rid of the troublesome type casts altogether.