Existence F in a String object initialization

What is the purpose of F in the 2nd code statement and what language it came from?
String htmlPage;
htmlPage = F(“HTTP/1.1 200 OK\r\n”
“Content-Type: text/html\r\n”);

The F() macro tells the compiler to leave this particular array in PROGMEM. Then when it is time to access it, one byte of the data is copied to RAM at a time. There’s a small performance overhead for this extra work. However, printing strings over Serial or to a LCD is a really slow process, so a few extra clock cycles really won’t matter.

ref: The hidden Arduino Macro F() fixes random lock ups - Bald Engineer

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.