4. Explore C++ code intelligence#

Sense’s integration with pw_ide enables fast and accurate code navigation, autocompletion based on a deep understanding of the code structure, and instant compiler warnings and errors. Try intelligent code navigation features now:

Explanation#

When you set your platform to rp2040 and followed the call to PW_LOG_INFO() in //apps/blinky/main.cc back to its source, you ended on a header within pw_log_tokenized. When you repeated the process a second time with the host_simulator platform you ended on a header in a different module, pw_log_string. This proves that intelligent code navigation is working. The pw_log API is a facade. It’s implementation is swapped out during compilation depending on what platform you’re building for. The rp2040 platform has been set up to use the pw_log_tokenized implementation, whereas the host_simulator platform uses the pw_log_string implementation.

Here’s a diagram summary of how the intelligent code navigation resolved to different files depending on the code analysis target you selected:

flowchart LR a["main.cc"] --> b["log.h"] b["log.h"] -. rp2040 .-> c["pw_log_tokenized/.../log_backend.h"] b["log.h"] -. host_simulator .-> d["pw_log_string/.../log_backend.h"]

Summary#

Portable, hardware-agnostic software abstractions such as pw_log make it easier to reuse code across projects and hardware platforms. But they also make it more difficult to correctly navigate references in your codebase. The Pigweed extension for VS Code can solve this problem; you just need to tell it what hardware platform within your codebase to focus on.

Next, head over to 5. Run host tests to learn how to run unit tests on your development host.