Red lines in editor, code still compiles

Hello,

I have migrated a program over from the old compiler and have some problems showing in the Keil Cloud editor underlined in red. This code compiled in the old compiler and still builds successfully in the Keil cloud compiler and the lines where the errors are showing still appear to work when the program is run. I have included here the header declarations, the variables showing a problem after declaration and the lines showing an error when using the variable.

#include “mbed.h”
#include “LCD_DISCO_F429ZI.h”
#include “main.h”
#include
#include

LCD_DISCO_F429ZI lcd;
Serial pc(USBTX, USBRX);

pc.printf(" ID = 0x%.3x\r\n", msg.id);

In this line “pc” is underlined in editor: error message is “Cannot initialize object parameter of type ‘mbed::Stream’ with an expression of type 'mbed::Serial’clang(member_function_call_bad_type)”

string serial=“”;
std::stringstream ss;
while (ECUType == 15) { // should only check this once
ECUType = getECUType(); // get ecu type and load global USN
int byteFromSerialNumber = 0;
for (int i=0 ; i<12 ; i++){
byteFromSerialNumber = (int)ECUSerialNumber[i];
ss << byteFromSerialNumber;
}
serial = ss.str();
The dot is underlined in the editor, with the error message: “Member reference base type ‘std::stringstream’ (aka ‘int’) is not a structure or unionclang(typecheck_member_reference_struct_union)”

cout << “VALD700:” << serial << endl;
the “<<” symbol is underlined here with error message: “Invalid operands to binary expression (‘std::ostream’ (aka ‘int’) and ‘const char [37]’)clang(typecheck_invalid_operands)”

Any help appreciated. This only the relevant lines of the code showing a problem. This code builds fine and in the Keil compiler as it did in the old compiler.
Mark

Hi Mark,

Thank you for reporting this issue. Unfortunately I can’t reproduce it with the information provided. I used Mbed OS 5.15.7. Would you mind telling us a little bit more about:

  • Mbed version you are using
  • Is the full source code available somewhere on source control management?

Thanks,
Arek - Studio team