<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Unable to enable the standard library in nRF Connect SDK 2.2.0</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94943/unable-to-enable-the-standard-library-in-nrf-connect-sdk-2-2-0</link><description>Hello, based on the Zephyr document C++ language support : the doc mentioned that Zephyr does not support templates, so pretty much 99% of the STL are NOT available. But in the paragraph, it says: 
 &amp;quot;Any application that makes use of the Standard Template</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 16 Dec 2022 13:06:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94943/unable-to-enable-the-standard-library-in-nrf-connect-sdk-2-2-0" /><item><title>RE: Unable to enable the standard library in nRF Connect SDK 2.2.0</title><link>https://devzone.nordicsemi.com/thread/401063?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2022 13:06:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7b49d29-792d-422d-a531-92a3e34b3e62</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You get the error because it is not allowed to set&amp;nbsp;CONFIG_REQUIRES_FULL_LIBC=y (it is used internally). A typical set of configurations sensible for using STL is:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_CPLUSPLUS=y
CONFIG_LIB_CPLUSPLUS=y
CONFIG_NEWLIB_LIBC=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I tested this on my end, taking the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.2.0/zephyr/samples/subsys/cpp/cpp_synchronization/README.html"&gt;C++ Synchronization sample&lt;/a&gt; and adding&amp;nbsp;#include &amp;lt;vector&amp;gt;, and this function that I call in the main loop (demonstrating some basic STL usage with vector):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void stl_stuff(void)
{
	std::vector&amp;lt;int&amp;gt; array;

	array.reserve(20);
	for(int i=0; i&amp;lt;5; ++i)
	{
		array.push_back(i);
	}

	printk(&amp;quot;Array capacity: %u\n&amp;quot;, array.capacity());
	printk(&amp;quot;Array size: %u\n&amp;quot;, array.size());

	for(const auto &amp;amp;element : array)
	{
    		printk(&amp;quot;Element value: %i\n&amp;quot;, element);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;That worked as expected on my end.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>