adding printf to print.h file

Hello,

I want to add printf to print.h using this tutorial but nothing happens.

https://web.archive.org/web/20180818192526/https://playground.arduino.cc/main/printf

I have edited print.h according to information under a link but still get the same error:

'class HardwareSerial' has no member named 'printf'

I have even deleted print.h and have in code:

Serial.println(F("Hello!"));

but Arduino IDE compiles with no error. Looks like print.h is not used during compilation... Maybe I should force somewhere to rebuild all

I have edited print.h

Great. My system has more than a dozen Print.h files. I'll bet yours does, too.

If only we knew which one you edited, and which board you are compiling for.

As you might have guessed from PaulS's reply, there may be multiple copies of Print.h on your computer, but the Arduino IDE is only going to use one of them. Which one may even depend on which board you have selected from the Tools > Board menu. That Arduino Playground page was written long ago, when the situation was more simple (but far inferior). If you're modifying a different version of Print.h than the one the Arduino IDE is using, that's going to cause some confusion for you.

The easiest way to find the active hardware package location is as follows:

  • Select a board from the hardware package you want to find from the Tools > Board menu
  • File > Examples > SPI > BarometricPressureSensor (or any other SPI example sketch)
  • Sketch > Show Sketch Folder
  • Move up folder levels until you reach the one that contains boards.txt

From there, you will find Print.h under the cores subfolder (often cores/arduino).