Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Compilation warnings with Keil MDK-ARM

Posted by Peter Smith on March 3, 2011
FreeRTOS6.1.1.
Cortex-M3
Keil MDK-ARM 4.14

Not sure what the following compiler warning implies, it may be a simple bug or something I am doing.

The warning is:-
..\..\..\Libraries\FreeRTOS/include/task.h(111): warning: #368-D: class "xTASK_PARAMTERS" defines no constructor to initialize the following:

The task.h file is included from a C++ source file

Don't understand as the extern "C" appears to be in place in the source files.

RE: Compilation warnings with Keil MDK-ARM

Posted by Dave on March 3, 2011
Do the FreeRTOS files compile ok? It might be that something should be compiling as a C file but is being incorrectly compiled as a C++ file.

RE: Compilation warnings with Keil MDK-ARM

Posted by Richard Damon on March 3, 2011
Sounds like the compiler is being over picky (I do note that it is just giving a warning and not an error, compilers are allowed to warn about anything they want)

structs and classes are allowed to not have constructors, and to be compatible with C, they can not have constructors (and be structs). The compiler is saying that this isn't a good idea as the members will not be automatically initialized, and it considers this not a good practice so it wishes to warn you about it.

There are a couple of options, one is to just turn off the warnings in the compiler options. A second, if you don't want to globally disable that warning, is to edit the file to add the appropriate pragma (assume the compiler provides one) to disable and restore the error around the piece of code giving the problem. This could be done in task.h, and need to be redone every time you update FreeRTOS, or in your source files just before including task.h, and need to be done in every file that does so (it might be worth creating a task.hpp that just does this and then includes task.h)

RE: Compilation warnings with Keil MDK-ARM

Posted by cpns on August 26, 2011
The problem is the
const signed char * const pcName;
member. The complete error message in uVision is missing because it does not handle multi-line messages from its own compiler! You need to look in the generated .lst file to see the fill message.

The semantics of const in C++ differ from C, but I am not sure why this generates a warning, it is a variable pointer to const data. That is not to say that the data is truly constant, but that it cannot be modified through this pointer. I think this warning can be safely disabled.
#pragma diag_suppress 368

RE: Compilation warnings with Keil MDK-ARM

Posted by Richard Damon on August 26, 2011
The issue is that extern "C" says to use C linkages, but DOESN'T compile the contents as C code. Compilers are also free to warn about anything they feel about.

In this case, the compiler sees a structure with a const member and no constructor. It expects that the proper way to initilize the structure would be in the constructor, but you can also use direct initilzation like in C. Because you don't have the constructor the compiler thinks it as suspicious, and so give the warning. (Note that it is defined as a const pointer to const signed char, so the element of the struct, the pointer, is const, thus you couldn't set it with something.pcName = "foo")


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS