inline Print &operator <<(Print &obj, T arg)

Hi,

I have recently tried to compile an old sketch I used 6 months or so ago but it will not compile with the following error:

inline Print &operator <<(Print &obj, T arg)

                                       ^
exit status 1
'T' has not been declared

Does anyone recognize this error? I'm guessing it's either a library that's been updated or a change in the Arduino IDE.

If so, is there something I can change about that line which would enable it to compile?

Many thanks

Please post the entire sketch(or better, a simplified sketch that demonstrates the issue). Which IDE version are you using?

I think the relevant part of the sketch as a whole is below:

template<class T> // no-cost stream operator as described at http://arduiniana.org/libraries/streaming/
inline Print &operator <<(Print &obj, T arg)
{
 obj.print(arg);
 return obj;
}

The IDE is version 1.6.8

The rule here is, whole code only. No snippets, only (possibly) compilable code as a whole...

septillion:
The rule here is, whole code only. No snippets, only (possibly) compilable code as a whole...

I understand, the trouble is that there is 9000 character limit on posts, so I can't post the whole code.

inline Print &operator <<(Print &obj, T arg)

You probably need that to be

inline Print &operator <<(Stream &obj, T arg)

Since the inheritance path changed, oh, back before arduino-0020... (6 month ago, eh?)
I'm not really enough of a C++ programmer to know if that will work, though.
You'd probably be better off with a newer version of the library: Streaming | Arduiniana
It's claimed to be 1.0 compatible for a while (probably since shortly after 1.0. We're at 1.6.7+ now...)

The multi line template is causing the error. You can it by changing it to:

template<class T> inline Print &operator <<(Print &obj, T arg)  // no-cost stream operator as described at http://arduiniana.org/libraries/streaming/
{
 obj.print(arg);
 return obj;
}

Automatic generation of function prototypes was changed to a new program, arduino-builder starting with Arduino IDE 1.6.6. In some cases this fails to correctly handle code that worked with the previous versions of the IDE. This issue was reported at Multiline templates not supported in sketch · Issue #43 · arduino/arduino-builder · GitHub but the developer decided that it would not be fixed and that only single line templates will be handled correctly.

pert:
The multi line template is causing the error. You can it by changing it to:

template<class T> inline Print &operator <<(Print &obj, T arg)  // no-cost stream operator as described at http://arduiniana.org/libraries/streaming/

{
obj.print(arg);
return obj;
}



Automatic generation of function prototypes was changed to a new program, arduino-builder starting with Arduino IDE 1.6.6. In some cases this fails to correctly handle code that worked with the previous versions of the IDE. This issue was reported at https://github.com/arduino/arduino-builder/issues/43 but the developer decided that it would not be fixed and that only single line templates will be handled correctly.

Thank you very much for this, it did indeed compile with this change!