Where can i find (and open in new tab) the library files .h and .cpp

Hello,

Simple question and i guess, simple answer.

To be clear: i’m not interested in creating a lib. I just want to see the code (.h and .cpp) in embedded libraries, in other tabs if possible. Seaching for one hour now.

thx!

Hi @mutmong. Try this:

  1. Open a sketch that contains code referencing something from a library you are interested in examining.
  2. Select the applicable board from Arduino IDE's Tools > Board menu.
    :warning: In some cases, the specific file that will be used by the compiler can be different depending on which board you are compiling for, so the information you gain by this procedure might be specific to the board you select.
  3. Select Sketch > Verify/Compile from the Arduino IDE menus.
    Alternatively, you can click the "Verify/Compile" button on the Arduino IDE toolbar.
  4. Wait for the compilation to finish.
  5. Right-click (Control-click for macOS users) on the code referencing something from the library in Arduino IDE's editor panel.
    In addition to normal code, you can also do this with the header filename in #include directive.
    A context menu will open.
  6. Select "Go to Definition" from the context menu.

The library file that contains the declaration or definition of the object you selected will open in an editor tab in Arduino IDE.

When you are finished looking at the file in the Arduino IDE editor, you can click the X icon on the editor tab to close it.

This feature is useful in the case where you want to get more information about something specific in your sketch code. It is less useful in the case where you want to study the library code as a whole. In that case, you should simply open the library files in a standard text editor, not Arduino IDE. If you don't already have a suitable text editor you use, I can recommend VS Code as an excellent professional grade programming editor.

Even in that case, Arduino IDE's "Go to Definition" feature can still be useful in locating the path of the library on your hard drive. You can find the path by hovering the mouse pointer over the Arduino IDE editor tab. After a second, a tooltip will appear that shows the path of the file on your hard drive.


:red_exclamation_mark: The file may be under a folder that is hidden by default by your operating system.


Thank you for your superfast answer. The “Go to definition” in the code (on the right spot) did it!…and i can keep on diggin’. thx!

You are welcome. I'm glad if I was able to be of assistance.

Regards, Per