FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [January 2010 Threads] compiler warning in tasks.cPosted by enken on January 10, 2010 I am getting the following compiler warning twice on line 422 in tasks.c "cast from pointer to integer of different size"
The line is: pxTopOfStack = ( portSTACK_TYPE * ) ( ( ( unsigned long ) pxTopOfStack ) & ( ( unsigned long ) ~portBYTE_ALIGNMENT_MASK ) );
compiled using mspgcc 3.2.3 and portBYTE_ALIGNMENT = 2
I've seen this warning since 6.0.0, still there in 6.0.2. Any pointers as to what could be done, is the error on my side/compiler?
RE: compiler warning in tasks.cPosted by Richard on January 11, 2010 I think this must be complaining about casting from pxTopOfStack to unsigned long. Presumably pxTopOfStack is of type portSTACK_TYPE *, which is unsigned short *.
Is the code working ok if you ignore the warning?
Regards.
RE: compiler warning in tasks.cPosted by enken on January 12, 2010 Yes, it's just a simple warning, tasks seem to execute fine. I'd like to get rid of it however, or at least understand why no one else seems to get this warning.
PS... looking forward to my PDF books...
RE: compiler warning in tasks.cPosted by enken on January 12, 2010 Hm! My first FreeRTOS report! There is a duplication of "#define tskIDLE_PRIORITY"
The first is in task.h : 127 The second is in tasks.c : 75
Hardly critical, but hey! A dupe's a dupe. Also shouldn't it be "task.c" instead of "tasks.c", to keep in line with the rest of your naming convention?
RE: compiler warning in tasks.cPosted by Richard on January 13, 2010 Hmm. That looks like a 'temporary' line that should have been removed. I have deleted the one in tasks.c. Thanks for pointing that out.
With regard to the header file name - yes that was a mistake that was made many, many years ago and is annoying. I have always left it because to change it would break peoples code.
I presume you got your PDF files?
Regards.
RE: compiler warning in tasks.cPosted by Mik Lamming on January 17, 2010 Richard, I'm getting the same error message with AVR Studio for Mega128. Is there some way to make it shut up please?
RE: compiler warning in tasks.cPosted by kevin on September 21, 2010 I made the following change to tasks.c. It preserves the "unsigned long" type used by the code. (Alternatively, I think "unsigned long" could be replace by uintptr_t if you rely on the C99 standard.)
/* * Union to allow application of alignment mask to "top of stack" * pointer without compiler warnings. */ typedef union topOfStackConversion { portSTACK_TYPE *pxTopOfStack; unsigned long ulTopOfStack; } topOfStackConv;
topOfStackConv xTopOfStack; ...
#if( portSTACK_GROWTH < 0 ) { xTopOfStack.pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 ); xTopOfStack.ulTopOfStack &= ( unsigned long ) ~portBYTE_ALIGNMENT_MASK; pxTopOfStack = xTopOfStack.pxTopOfStack; } #else
Reference: https://www.securecoding.cert.org/confluence/display/cplusplus/INT11-A.+Take+care+when+converting+from+pointer+to+integer+or+integer+to+pointer
RE: compiler warning in tasks.cPosted by kevin on September 21, 2010 I should add that I only tested this with the AVR GCC tools for an ATxmega128A1. I did a brief search, but other than my original reference, I did not find any guarantees about the alignment of the different types in the union. I don't suggest you blindly use this without testing it on your specific platform.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|