Odd compiler warnings.

26 Aug 2010 . Edited: 26 Aug 2010

I have some old code (rather a lot actually) that I port around and use here and there. Well, ported into a project here on Mbed.

As expected with using a modern compiler with old code I had some warnings, so I dusted these off with a spring clean of the code. The problem is I am now left with a number of  warnings I can't appear to do anything about as they seem to be within teh compiler enviroment. Here's the warnings (darn it, can't c'n'p warnings!):-

[1] <__c.0> may be used before being set     fstream.cc  /opt/RVDS4/RVCT/Data/4.0/400/include/unix   Line: 674 Col 10
[2] <__c.0> may be used before being set     streambuf   /opt/RVDS4/RVCT/Data/4.0/400/include/unix   Line: 394 Col 12
[3] as [2] above Line 473 Col 6
[4] repeat of [3]
[5] <__c.0> may be used before being set     ostream     /opt/RVDS4/RVCT/Data/4.0/400/include/unix   Line: 301 Col 6
[6] repeat of [5]
[7] repeat of [2]
[8] repeat of [3]

Is there a way from the preprocessor to disable these warnings? I have no idea what code files I have that may be responsible for creating these warnings as there's not enough info to backtrace to the src. Not even sure if there's a real problem with the code or not as I can't see what the compiler is complaining about at all.

27 Aug 2010

Those warnings come from the use of stream classes, and the use of streams and the STL is not currently supported, although there is a low-priority bug already open on this. However, using the stream classes does eat up quite a large chunk of RAM, of which the LPC1768 only has 32K available to applications to play with (after you remove the Ethernet, CAN and USB RAM), so you may want to consider using some classic C methods of string and IO handling anyway.

27 Aug 2010 . Edited: 27 Aug 2010

I found this earlier in the week, it's actually just using bitfields that causes the warning.


I doubt you can actually change the code to fix the warning, as it looks like it's in a lib, but If you initialise the struct with ={0}; then the warning is fixed.

(This is because if you only initialise some of the elements of a struct with {} then the remaining elements will be initialised automatically)