Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 3 months ago.
Structs causing C4017W compiler warning
I'm trying to create a struct called Color that contains several public variables, as well as some helpful constructors and methods. However, I'm getting inconsistent C4017W compiler warnings every time I create an instance of the struct. Here is a simplified test program that demonstrates the warning:
Test Program
#include "mbed.h" //Color struct struct Color { char red; char green; char blue; Color(char r, char g, char b) { red = r; green = g; blue = b; } }; int main() { //Create a test Color and print it Color color(0xAD, 0xBE, 0xEF); printf("color: (0x%02X, 0x%02X, 0x%02X)\n", color.red, color.green, color.blue); //Don't exit main! while(1); }
And here are the results of compiling it:
The inline constructor in the test program issues a C4017W every time. My main code, however, is using a separate implementation file for the constructors and methods, and it doesn't issue any warnings until I add a fourth variable for alpha. To make matters more interesting, if I move the constructor in the test program to a separate implementation file and add a fourth variable for alpha, the warning disappears! What the heck am I doing wrong here? Is this a compiler bug?