<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: error: &#039;string&#039; does not name a type</title>
		<link>http://forums.leaflabs.com/topic.php?id=2830</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:27:31 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=2830" rel="self" type="application/rss+xml" />

		<item>
			<title>sylvain on "error: &#039;string&#039; does not name a type"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2830#post-13471</link>
			<pubDate>Mon, 10 Sep 2012 02:29:52 +0000</pubDate>
			<dc:creator>sylvain</dc:creator>
			<guid isPermaLink="false">13471@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'm trying to port some of my Arduino code to Maple and I'm running into some problems. This time it looks like a bug.&#60;/p&#62;
&#60;p&#62;I've got these includes&#60;br /&#62;
&#60;code&#62;&#60;br /&#62;
#include &#38;lt;stdlib.h&#38;gt;&#60;br /&#62;
#include &#38;lt;string&#38;gt;&#60;br /&#62;
#include &#38;lt;sstream&#38;gt;&#60;br /&#62;
#include &#38;lt;Wire.h&#38;gt; //I2C library&#60;br /&#62;
#include &#38;lt;I2C_eeprom.h&#38;gt;&#60;br /&#62;
#include &#38;lt;TinyGPS.h&#38;gt;&#60;br /&#62;
#include &#38;lt;track.h&#38;gt;&#60;br /&#62;
&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;And a function using std::string like this:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
//Pad the incoming long with 0 to length&#60;br /&#62;
std::string pad(long num, int length) {&#60;br /&#62;
  std::string number;&#60;br /&#62;
  std::stringstream strstream;&#60;br /&#62;
  strstream &#38;lt;&#38;lt; num;&#60;br /&#62;
  strstream &#38;gt;&#38;gt; number;&#60;/p&#62;
&#60;p&#62;  int str_length = number.length();&#60;br /&#62;
  for (int i = 0; i &#38;lt; length - str_length; i++)&#60;br /&#62;
    number = &#34;0&#34; + number;&#60;br /&#62;
  return number;&#60;br /&#62;
}&#60;br /&#62;
&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;This should all work, were it not that the cpp file generated (by the IDE, I suppose) is missing the std:: namespace for the function declaration. The code generated looks like this:&#60;br /&#62;
&#60;code&#62;&#60;br /&#62;
#include &#38;lt;stdlib.h&#38;gt;&#60;br /&#62;
#include &#38;lt;string&#38;gt;&#60;br /&#62;
#include &#38;lt;sstream&#38;gt;&#60;br /&#62;
#include &#38;lt;Wire.h&#38;gt; //I2C library&#60;br /&#62;
#include &#38;lt;I2C_eeprom.h&#38;gt;&#60;br /&#62;
#include &#38;lt;TinyGPS.h&#38;gt;&#60;br /&#62;
#include &#38;lt;track.h&#38;gt;&#60;/p&#62;
&#60;p&#62;#include &#34;WProgram.h&#34;&#60;/p&#62;
&#60;p&#62;void setup();&#60;br /&#62;
void loop();&#60;br /&#62;
string pad(long num, int length);&#60;br /&#62;
&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Obviously, omitting the std:: namespace will not work. Is there a quick workaround for this? I tried to manually declare everything, hoping that the IDE would pick that up and not try to do it itself...
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
