Poking through the example code of SDFS, I saw the following:

static ArduinoOutStream cout(Serial);
// F stores strings in flash to save RAM
cout << F("\ntype any character to start\n");

What exactly is << doing in this case? Moreover, F seems to never be defined prior to this. This seems like a useful trick, but I don't understand how it works.

full code available here: https://github.com/greiman/SdFs/blob/master/examples/SdInfo/SdInfo.ino

2 Answers 2


What exactly is << doing in this case?

It's directing the data into an output device (stream).

Yes, it's confusing using the same symbols for more than one thing...

Moreover, F seems to never be defined prior to this.

F() is a macro. It's defined by the Arduino core in WString.h:

#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
  • Thank you. Your last line there uses the < and > symbols in ways I've never seen as well, along with the pointer. These seem not to be logical or arithmetic operators, so what do I call them in a google search to understand your answer? Commented Feb 21, 2019 at 22:13
  • @BoThompson those are template<parameters>
    – esoterik
    Commented Feb 21, 2019 at 22:21
  • Compared to the < logical operator and the < arithmetic operator, what would you call that set of symbols? Commented Feb 21, 2019 at 22:35

To address your confusion with the bitshift operator;

It indeed is commonly used as a the arithmetic operator for bitshift, but appears to be 'overloaded', so that when used with streams, it is an 'insertion operator'.

In particular, stream insertion and stream extraction overloads of operator<< and operator>> return T&.


Basically there would be two definitions of the "<<" operator function:

function <<(integer){//Shift bits}
function <<(stream){//Join streams}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.