From: Adrian Freihofer Date: Tue, 3 Feb 2026 22:16:27 +0000 (+0100) Subject: cpp-example: Add std::vector example X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4e8ff14ab51892bdcb176b9eef2741286597db8;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git cpp-example: Add std::vector example Add a standard container (std::vector) to the C++ example program to demonstrate the debugger's capability to inspect and traverse STL containers during a debugging session. This requires enabling GDB's pretty-printing feature, which depends on Python scripts shipped with the compiler. Signed-off-by: Adrian Freihofer Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- diff --git a/meta-selftest/recipes-test/cpp/files/cpp-example.cpp b/meta-selftest/recipes-test/cpp/files/cpp-example.cpp index dbf82f15d9..23d7169092 100644 --- a/meta-selftest/recipes-test/cpp/files/cpp-example.cpp +++ b/meta-selftest/recipes-test/cpp/files/cpp-example.cpp @@ -9,6 +9,7 @@ #include #include #include +#include int main(int argc, char* argv[]) { @@ -50,5 +51,12 @@ int main(int argc, char* argv[]) } } while (endless_mode); + // Example: Demonstrate std::vector traversal for debugger inspection + std::vector numbers = {1, 2, 3}; + std::cout << "Traversing std::vector numbers:" << std::endl; + for (size_t i = 0; i < numbers.size(); ++i) { + std::cout << "numbers[" << i << "] = " << numbers[i] << std::endl; + } + return 0; }