<?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: Overwriting main()</title>
		<link>http://forums.leaflabs.com/topic.php?id=583</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:16:59 +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=583" rel="self" type="application/rss+xml" />

		<item>
			<title>Darth Maker on "Overwriting main()"</title>
			<link>http://forums.leaflabs.com/topic.php?id=583#post-3295</link>
			<pubDate>Tue, 04 Jan 2011 22:02:57 +0000</pubDate>
			<dc:creator>Darth Maker</dc:creator>
			<guid isPermaLink="false">3295@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I like to have full control of the program flow, and it doesn't feel like C(++) with the main() function hidden.  Obviously, using Setup() and Loop() works fine for most programs, but hiding the while loop bugs me, since there isn't a logical reason that Loop() should loop without it.  And if you do everything in Setup(), then you have this Loop() function hanging off the end that doesn't do anything.&#60;/p&#62;
&#60;p&#62;But the real reason is just that I'm stubborn and want my own main() function.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>soundcyst on "Overwriting main()"</title>
			<link>http://forums.leaflabs.com/topic.php?id=583#post-3284</link>
			<pubDate>Mon, 03 Jan 2011 13:14:08 +0000</pubDate>
			<dc:creator>soundcyst</dc:creator>
			<guid isPermaLink="false">3284@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;.cxx is a variant of c++ file extension, the x's being +'s that have been rotated 45 degres.  .cc is also common, though i think .cpp is the most common..&#60;/p&#62;
&#60;p&#62;out of curiosity, what's your motivation for changing main() besides that it's how you learned C?  are you actually changing the setup and init procedures, or just sticking to your guns?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Darth Maker on "Overwriting main()"</title>
			<link>http://forums.leaflabs.com/topic.php?id=583#post-3276</link>
			<pubDate>Sun, 02 Jan 2011 01:52:53 +0000</pubDate>
			<dc:creator>Darth Maker</dc:creator>
			<guid isPermaLink="false">3276@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks for the answer.  Sorry I didn't get back sooner, my pc was unexspectedly down for a couple days, and I didn't/don't have access to my bookmarks.&#60;/p&#62;
&#60;p&#62;Interestingly, I've found that I can modify the main.cxx (odd file type?) file, and it will compile the changes.  So that will probably get me where I want to go.&#60;/p&#62;
&#60;p&#62;It doesn't seem like it would be too difficult to make the core into a library, and wouldn't it compile faster?  Anyway, I can see that not having it a library would make it a lot easier to build and test new parts of the core.&#60;/p&#62;
&#60;p&#62;A couple minutes later...&#60;/p&#62;
&#60;p&#62;I am totally set.  I can comment the entire main() function from the main.cxx file, then write my own the the IDE and it compiles fine.  Backwards compatibility is only a small issue, since I can just add the calls to setup() and loop() in my own main() function.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Overwriting main()"</title>
			<link>http://forums.leaflabs.com/topic.php?id=583#post-3238</link>
			<pubDate>Mon, 27 Dec 2010 17:24:12 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">3238@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;by the way, init() lives here:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://github.com/leaflabs/libmaple/blob/master/wirish/wirish.c&#34; rel=&#34;nofollow&#34;&#62;https://github.com/leaflabs/libmaple/blob/master/wirish/wirish.c&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Overwriting main()"</title>
			<link>http://forums.leaflabs.com/topic.php?id=583#post-3237</link>
			<pubDate>Mon, 27 Dec 2010 17:23:06 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">3237@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;hi darth maker,&#60;/p&#62;
&#60;p&#62;not sure what you mean by &#34;it added the code into the built-in main() function&#34;.  the current implementation just writes main() for you (along with a premain() method that runs before it and calls init()).  it's not a question of adding code to an existing main function; rather, the IDE's preprocessing step just inserts a definition.  the implementation is here:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://github.com/leaflabs/libmaple/blob/master/wirish/main.cxx&#34; rel=&#34;nofollow&#34;&#62;https://github.com/leaflabs/libmaple/blob/master/wirish/main.cxx&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;unlike the arduino environment, the maple ide doesn't currently allow you to define your own main() function.  it seems reasonable to allow that in a future release.  however, in the meantime, maybe you can try treating setup() like main()?  as long as your setup() doesn't return, and you don't have any objections to the default init(), that should be equivalent.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Darth Maker on "Overwriting main()"</title>
			<link>http://forums.leaflabs.com/topic.php?id=583#post-3214</link>
			<pubDate>Sat, 25 Dec 2010 20:19:33 +0000</pubDate>
			<dc:creator>Darth Maker</dc:creator>
			<guid isPermaLink="false">3214@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I been using an Arduino UNO for a while, but I learned C using the main() function.  So when I want to do Arduino work, I write my own main() function (including the call to init().  I believe the built-in main() function is a library, so it overwrites it with my code.&#60;/p&#62;
&#60;p&#62;When I attempted this same thing with the Maple IDE, it failed to compile with an error, within main(), that int main() was redeclared.  So instead of overwriting, it added the code into the built-in main() function.&#60;/p&#62;
&#60;p&#62;So maybe the Maple IDE built-in main() needs to be made a/part of a library?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
