<?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; User Favorites: JBernardo</title>
		<link><a href='http://forums.leaflabs.com/profile.php?id=3737'>3737</a></link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:23:26 +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?profile=3737" rel="self" type="application/rss+xml" />

		<item>
			<title>JBernardo on "Dynamic allocation - malloc"</title>
			<link>http://forums.leaflabs.com/topic.php?id=760#post-4552</link>
			<pubDate>Tue, 10 May 2011 19:48:23 +0000</pubDate>
			<dc:creator>JBernardo</dc:creator>
			<guid isPermaLink="false">4552@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I was probably including &#60;code&#62;stdlib.h&#60;/code&#62; after other libraries...&#60;/p&#62;
&#60;p&#62;Anyway, accessing static variables from a class keep resulting in undefined references... The way I solved the problem was declaring &#60;code&#62;instance&#60;/code&#62; inside &#60;code&#62;Box::get()&#60;/code&#62; as static, of course.&#60;/p&#62;
&#60;p&#62;The program is now working happily.&#60;/p&#62;
&#60;p&#62;Thanks
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Dynamic allocation - malloc"</title>
			<link>http://forums.leaflabs.com/topic.php?id=760#post-4535</link>
			<pubDate>Mon, 09 May 2011 14:15:58 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">4535@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;JBernardo,&#60;/p&#62;
&#60;p&#62;The abs() problem is a known issue which will get fixed; perhaps this thread may be useful to you in the meantime:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=663&#38;amp;replies=10#post-3755&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=663&#38;amp;replies=10#post-3755&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>JBernardo on "Dynamic allocation - malloc"</title>
			<link>http://forums.leaflabs.com/topic.php?id=760#post-4526</link>
			<pubDate>Sun, 08 May 2011 21:20:05 +0000</pubDate>
			<dc:creator>JBernardo</dc:creator>
			<guid isPermaLink="false">4526@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Weird... the problem on &#60;code&#62;stdlib.h&#60;/code&#62; stopped showing, but I keep having undefined reference to my object pointer.&#60;/p&#62;
&#60;p&#62;Somehow I can't find the file I was working on, but among other things, I had something like this:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;class Box{
public:
  static Box&#38;amp; get();

private:
  Box();
  static Box *instance;

};

Box::Box(){
  instance = 0;
}

Box&#38;amp; Box::get(){
  if (!instance){
    instance = (Box *) malloc(sizeof(Box));
  }
  return *instance;
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Dynamic allocation - malloc"</title>
			<link>http://forums.leaflabs.com/topic.php?id=760#post-4522</link>
			<pubDate>Sun, 08 May 2011 08:19:53 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">4522@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I don't get any errors when I&#60;br /&#62;
&#60;code&#62;#include &#38;lt;stdlib.h&#38;gt;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;I haven't run it, but the code:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;char *p = (char*)malloc(10);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;compiles fine. &#60;/p&#62;
&#60;p&#62;I'd assume there is something else wrong.&#60;br /&#62;
Try copying the file then cutting it down until the error becomes clearer.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>JBernardo on "Dynamic allocation - malloc"</title>
			<link>http://forums.leaflabs.com/topic.php?id=760#post-4520</link>
			<pubDate>Sun, 08 May 2011 00:44:42 +0000</pubDate>
			<dc:creator>JBernardo</dc:creator>
			<guid isPermaLink="false">4520@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi there,&#60;/p&#62;
&#60;p&#62;Well, I do understand &#60;code&#62;new&#60;/code&#62; and &#60;code&#62;delete&#60;/code&#62; are not allowed to work on Wiring, but, &#60;code&#62;malloc&#60;/code&#62; doesn't work either unlike Arduino.&#60;/p&#62;
&#60;p&#62;There's a problem when I include &#60;code&#62;stdlib.h&#60;/code&#62; because of the following errors:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;/media/Dados/dev/.../include/stdlib.h:72: error: expected unqualified-id before &#38;#39;int&#38;#39;
/media/Dados/dev/.../include/stdlib.h:72: error: expected &#38;#39;)&#38;#39; before &#38;#39;int&#38;#39;
/media/Dados/dev/.../include/stdlib.h:72: error: expected &#38;#39;)&#38;#39; before &#38;#39;int&#38;#39;
/media/Dados/dev/.../include/stdlib.h:72: error: expected &#38;#39;)&#38;#39; before &#38;#39;int&#38;#39;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;And those are lines 71 to 74 from &#60;code&#62;stdlib.h&#60;/code&#62;:&#60;/p&#62;
&#60;p&#62;_VOID	_EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn)));&#60;br /&#62;
&#60;strong&#62;int	_EXFUN(abs,(int));&#60;/strong&#62;&#60;br /&#62;
int	_EXFUN(atexit,(_VOID (*__func)(_VOID)));&#60;br /&#62;
double	_EXFUN(atof,(const char *__nptr));&#60;/p&#62;
&#60;p&#62;This is not much meaningful...&#60;/p&#62;
&#60;p&#62;When I comment this line, some undefined reference errors appear on a pointer (the one I'm trying to allocate) to my object.&#60;/p&#62;
&#60;p&#62;I'm not sure what to do except to change the design of the program ...&#60;/p&#62;
&#60;p&#62;I also tried &#60;code&#62;placement new&#60;/code&#62; but doesn't seems to work (including &#60;code&#62;&#38;lt;new.h&#38;gt;&#60;/code&#62; doesn't change anything)&#60;/p&#62;
&#60;p&#62;Any thoughts?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
