<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code Reactor</title>
	<atom:link href="http://www.codereactor.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codereactor.net</link>
	<description>The best of modern Web development</description>
	<lastBuildDate>Wed, 01 Feb 2012 12:32:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>All the Visual Studio color themes you will ever need</title>
		<link>http://www.codereactor.net/all-the-visual-studio-color-themes-you-will-ever-need/</link>
		<comments>http://www.codereactor.net/all-the-visual-studio-color-themes-you-will-ever-need/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 22:55:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=261</guid>
		<description><![CDATA[Combining two great concepts in programming world &#8211; color themes and the StackOverflow engine, http://studiostyl.es gives you a one-stop place for all the nice Visual Studio color themes. No more searching &#8220;the ogl&#8221; for themes and typing them in manually into the settings window. All the themes can be downloaded for all the latest versions of VS, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codereactor.net/wp-content/uploads/2012/01/vsthemes.jpg"><img class="alignright size-full wp-image-262" title="vsthemes" src="http://www.codereactor.net/wp-content/uploads/2012/01/vsthemes.jpg" alt="" width="295" height="86" /></a></p>
<p>Combining two great concepts in programming world &#8211; color themes and the StackOverflow engine, <a href="http://studiostyl.es/">http://studiostyl.es</a> gives you a one-stop place for all the nice Visual Studio color themes. No more searching &#8220;the ogl&#8221; for themes and typing them in manually into the settings window.</p>
<p>All the themes can be downloaded for all the latest versions of VS, however it is still not particularly user friendly to install them, at least not in VS2008. I hope their coders are at least a little bit ashamed, but hey, it&#8217;s not like this is the primary point of VS.</p>
<p>In VS2008, you just download the file, and in Options &gt; Environment &gt; Import And Export Settings point the &#8220;team settings file&#8221; to the file you&#8217;ve downloaded. If you already had a team setting file, I can&#8217;t really help you, but the settings are just an XML so you could easily migrate them into your personal settings file using your favorite text editor.</p>
<p>(Update: found it, it is much simpler to install those using Tools &gt; Import And Export Settings.)</p>
<p>(Yet Another Update: here is where I took my theme needs before the studiostyl.es came along: <a href="http://www.hanselman.com/blog/VisualStudioProgrammerThemesGallery.aspx">http://www.hanselman.com/blog/VisualStudioProgrammerThemesGallery.aspx</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/all-the-visual-studio-color-themes-you-will-ever-need/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some MS-lovin</title>
		<link>http://www.codereactor.net/some-ms-lovin/</link>
		<comments>http://www.codereactor.net/some-ms-lovin/#comments</comments>
		<pubDate>Sun, 25 Sep 2011 00:46:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=243</guid>
		<description><![CDATA[Aah, good old MS api class for representing the &#8220;system enclosure&#8221;, ie, what type of computer you have. Except: 1 Other 2 Unknown 3 Desktop 4 Low Profile Desktop 5 Pizza Box 6 Mini Tower 7 Tower 8 Portable 9 Laptop 10 Notebook 11 Hand Held 12 Docking Station 13 All in One 14 Sub [...]]]></description>
			<content:encoded><![CDATA[<p>Aah, good old MS api class for representing the &#8220;system enclosure&#8221;, ie, what type of computer you have. Except:</p>
<p>1<br />
Other<br />
2<br />
Unknown<br />
3<br />
Desktop<br />
4<br />
Low Profile Desktop<br />
5<br />
Pizza Box<br />
6<br />
Mini Tower<br />
7<br />
Tower<br />
8<br />
Portable<br />
9<br />
Laptop<br />
10<br />
Notebook<br />
11<br />
Hand Held<br />
12<br />
Docking Station<br />
13<br />
All in One<br />
14<br />
Sub Notebook<br />
15<br />
Space-Saving<br />
16<br />
Lunch Box<br />
17<br />
Main System Chassis<br />
18<br />
Expansion Chassis<br />
19<br />
SubChassis &#8230;</p>
<p>Pizza Box!? Lunch box!?</p>
<p>&#8220;Missing good old 80es when you ran dos on a pizza box&#8230;</p>
<p>(as seen on http://msdn.microsoft.com/en-us/library/Aa394474 and http://stackoverflow.com/questions/2837152/how-can-i-tell-if-a-user-is-using-a-laptop</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/some-ms-lovin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hardcore debugging crashes in C++ release builds in Visual Studio and StackWalker</title>
		<link>http://www.codereactor.net/hardcore-debugging-crashes-in-c-release-builds-in-visual-studio-and-stackwalker/</link>
		<comments>http://www.codereactor.net/hardcore-debugging-crashes-in-c-release-builds-in-visual-studio-and-stackwalker/#comments</comments>
		<pubDate>Mon, 30 May 2011 20:47:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=220</guid>
		<description><![CDATA[Ever encountered an error which just shows up in a release build? And when you are debugging everything is just fine? Don&#8217;t those errors just make you happy and loving the programming, computers, the world and everything in it? So, long story short, I had to come up with some reliable debugging methods for the [...]]]></description>
			<content:encoded><![CDATA[<p>Ever encountered an error which just shows up in a release build? And when you are debugging everything is just fine? Don&#8217;t those errors just make you happy and loving the programming, computers, the world and everything in it? <img src='http://www.codereactor.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>So, long story short, I had to come up with some reliable debugging methods for the release builds, and there are quite a few.<br />
<span id="more-220"></span></p>
<h2>Internal methods</h2>
<p>Well, just to mention, of course, there is logging. However, my error was producing a nice and loud access violation and quitting, so instead of starting to log everything that happens I wanted to start working from that AV. But do not undermine the power</p>
<p><strong>Try/catch</strong></p>
<p>Firs on my list is the good old c++ try/catch blocks. In case of debugging crashes you can use them by just putting the main() or WinMain in one big try/catch, and get the exception object in the catch and start working from there. Based on that object you can deduce the exact error, line, sometimes even the callstack (probably the single most valuable piece of information about a crash). Nothing out of the ordinary, plain and simple.</p>
<p>However, this method will only catch c++ exceptions, not the hardware errors or even things like bad pointers, which is quite a pity because most of bugs lead just to those.</p>
<p>wait, what?- you say, try does not catch all the errors? What is the point then?</p>
<p>Well, basically, there are two kinds of exceptions in C++. First one is</p>
<ol>
<li> C++ exceptions. These are the errors the code is sort of throwing itself. For example, you download a library for opening image files, and calling a function for opening a jpeg. However it cannot open the file, and uses c++ Throw() to throw an exception, to report that something went wrong and processing of that function has stopeed.<br />
The control now goes back to your innermost try/catch block and you get your exception there.<br />
These errors are always thrown by the code itself. It may not be your code, but somewhere there is a Throw() that wants to signal that something went wrong, but it knows about it.<br />
So these errors are handled in the c++ code, basically by the compiler, and even though they are errors, they are sort of already managed, at least partly. Because somwhere there is a throw, and its purpose is to manage an error.<br />
These errors a pretty high-level compared to the SEH exceptions, can basically be used as a valid control structure, not only as a fail-safe mechanism. You are free to use try/catch blocks to catch these exceptions through arbitrary calling levels, cycles, and so on. The compiler will automatically free all the memory when it unwinds the call stack to get to your innermost catch block.</li>
<li>SEH exceptions. (and this is windows-specific)<br />
Now, let&#8217;s say you are doing a simple *i = 1;, where i is a pointer that for some reason is pointing to null. This means your program will try to access memory at the very beginning (0) of the address space, and that memory is very reserved, so the operation is invalid.<br />
But what happens? You have obviously not written any code to Throw() an exception to manage this error. In fact, if you were aware of that this could happen, you could&#8217;ve just checked if i is equal to 0, and not assign a value in that case.<br />
Of course, other scenarios are possible, but bottomline is that sometimes there are operations that produce errors on the assembly level. The bugs (poorly designed code) probably happen before, and lead to these situations, but nevertheless, when this happens, neither the compiler nor the processor know what to do, they cannot analyze the code for you, they just see that something is wrong. Which brings us to</li>
</ol>
<p><strong>_try/_except</strong></p>
<p>To handle these low-level errors, MS gave us a non-standard extesion to C++, which can be used in visual C++: __try and __except. The OS itself of course has a mechanism for handling these errors, otherwise any poor-written program would be able to cause havoc. There are WINAPI functions for setting SEH exception handlers, getting information about the error and so on. And in Visual C++ we can catch these errors using __try. (If you are on other platforms or other compilers, this section might be of no use to you).</p>
<p>Now, you might ask why isn&#8217;t this a standard C++ thing, these are still errors? The usual argumentation is that while C++ exceptions might be thrown by design (instead of constructing a lot of if&#8217;s, an author of a problematic function just put a throw() and was done with it), SEH errors often represent serious bugs in the program, and the chance is not big that the program will be able to recover from it, and this is why simply putting a try/catch around a SEH exception and trying to mask it is much more dangerous than doing so with a C++ exception. (For example it could cause a damaged information to be written to disk, instead of just being damaged in a memory)</p>
<p>This is of course, true to some extent, but hey, as long as you know where and how to use it, an error log during debugging is much better than just a binary dump saved by Windows&#8217; default error mechanism.</p>
<p>Basically, if you put a try/catch block around your error, but it doesn&#8217;t catch it, try _try/_except. But you will need some other things to make it useful, for example StackWalker, a class to parse all the information from the SEH handler and print it to a nice readable stack trace. (Even with line numbers! And even in release builds! It is very simple to use and all the examples are provided in http://www.codeproject.com/KB/threads/StackWalker.aspx, so I am not going to cite them here.)</p>
<p>Just before we continue, there are some specialties in how VC++ compiles, first which errors are catched by normal try/catch can depend on whether you are building a debug or a release build, this is supposedly a bug in an older version of the compiler. Secondly, there are some compiler switches to make try/catch catch *all* errors in all types of builds (/EH{s|a}[c][-], http://msdn.microsoft.com/en-us/library/1deeycx5(v=vs.71).aspx), but there are a ton of information about this around the google and StackOverflow&#8230;</p>
<p>&nbsp;</p>
<h2>Proper IDE-debugging</h2>
<p>A very important fact that you may or may not know is that debugging  in an IDE does not actually require the binary to be built in any special way (i.e. debug configuration). The  debugger could go into any userlevel program and start stepovering and  stepintoing, except in some very special cases. So what is the debug configuration really good for, except slowing down the program you ask? Well I wonder that too sometimes, but basically it adds some extra checks for things that can go wrong (a LOT of checks in STL for example), which can sometimes get you a more comprehend-able error than without those checks. Nevertheless, it is in now way a *requisite* to IDE debugging.</p>
<p>But what is an (almost) requisite are the symbols. The symbols are human-readable markers of things in your binary, like functions and c++ lines. When debugging, it is a lot easier to understand what is going on if the debugger tells you that you are in function suchAndSuch(), on line 342, instead of &#8220;You are at location 0x00400F3d&#8221;.</p>
<p>Those symbols are saved in a separate file (.pdb), and saving them contra not saving them does not modify the  binary itself, so it will run exactly like a binary without those debug  symbols, and will most probably crash at the same place (which is what  you want to debug).</p>
<p>Long story short, you will need these settings:<br />
1) C/C++ &gt; Debug Information Format: /Zi or /ZI, chances are you won&#8217;t have to change this from the default value.<br />
2) Linker &gt; Debugging &gt; Generate Debug Info : YES /DEBUG<br />
3) Linker &gt; Optimization &gt; References: Eliminate Unreferenced Data (/OPT:REF) and Linker &gt; Optimization &gt; Enable COMDAT Folding &gt; Remove Redundant COMDATs (/OPT:ICF). Without going into too much detail about these options, when you set the /DEBUG option, that modifies the default behavior of the linker regarding comdats and references, and by setting these two options you modify those behavior back to the way it is without the /DEBUG option, thus making sure your binary will be the same.</p>
<p>The symbols file will be saved by default in some intermediate directory for your project. While debugging, the IDE will have to find that file.</p>
<p>An interesting fact: by default, Visual Studio stores absolute path to your symbols file in your binary. This is good for debugging on the same machine, because no matter where you start your binary from, if it is debugged in Visual Studio, it will always find the symbols, but if you need to debug on different machines or just think that it is not in any way pro to ship your binaries with absolute paths to things on your development machine in them (like me), you can make it store the relative path with an undocumented command line switch: &#8220;/pdbpath:none &#8220;. (source: http://groups.google.com/group/microsoft.public.vc.debugger/browse_thread/thread/abbbdead63dfe5ac?pli=1)</p>
<p>&nbsp;</p>
<p>So that basically should get you started on debugging release builds, for more info, google is always your dearest friend!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/hardcore-debugging-crashes-in-c-release-builds-in-visual-studio-and-stackwalker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook PHP compiler</title>
		<link>http://www.codereactor.net/facebook-php-compiler/</link>
		<comments>http://www.codereactor.net/facebook-php-compiler/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 23:16:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=211</guid>
		<description><![CDATA[More and more php compilers are emerging, and it now finally looks like there are a number of decent ones out there. Just a couple of years ago, there only were bcompiler, eaccelerator and perhaps some others, but none really good. Eaccelerator would be sensitive to server environment and only work under certain conditions, and [...]]]></description>
			<content:encoded><![CDATA[<p>More and more php compilers are emerging, and it now finally looks like there are a number of decent ones out there.</p>
<p>Just a couple of years ago, there only were bcompiler, eaccelerator and perhaps some others, but none really good. Eaccelerator would be sensitive to server environment and only work under certain conditions, and even have special problems with different php programs, and others had similair problems.</p>
<p>But now it seems like there are 5-10 different compilers, and all seem to work really nice. An especially interesting one is HipHop for PHP &#8211; a php compiler written by facebook to run in their own servers. The ultimate goal of all compilers is the SPEED (and, hwell, perhaps, obsfucation too), and I can only imagine what kind of speed problems the facebook experiences, with all their traffic, so if hiphop is good for them, then it should be too for the rest of the normal mortal aplications out there.</p>
<p>One important thing to know though is that hiphop for PHP is not an opcode cacher or a JIT. It is actually a compiler, and produces binary code as such. Probably because of that it has problems with eval() and some other dynamic features of PHP. If that is the case with your application, then it&#8217;s probably not for you, but how often does one really use eval?</p>
<p>Definetely check it out if you are looking to speed up your php application without changing a line of code. ﻿<a href="http://developers.facebook.com/blog/post/358/">http://developers.facebook.com/blog/post/358/</a></p>
<p><a href="http://developers.facebook.com/blog/post/358/"></a>Github: <a href="https://github.com/facebook/hiphop-php/wiki/">https://github.com/facebook/hiphop-php/wiki/</a></p>
<p><a href="https://github.com/facebook/hiphop-php/wiki/"></a>﻿</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/facebook-php-compiler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Anonymity in 2010</title>
		<link>http://www.codereactor.net/anonymity-in-2010/</link>
		<comments>http://www.codereactor.net/anonymity-in-2010/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 17:43:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=142</guid>
		<description><![CDATA[A great podcast/presentation that has started to circulate around the blogosphere, about how the internet and the progress is affecting our anonymity. Steve Rambam (who is/was a private investigator, and ironically looks very much like one, thou also like an italian mafia boss) takes on many interesting things in this 3 hour long talk, including [...]]]></description>
			<content:encoded><![CDATA[<p>A great podcast/presentation that has started to circulate around the blogosphere, about how the internet and the progress is affecting our anonymity.</p>
<p>Steve Rambam (who is/was a private investigator, and ironically looks very much like one, thou also like an italian mafia boss) takes on many interesting things in this 3 hour long talk, including<br />
- What information we are putting in &#8220;The Database&#8221; ourselves and how the way people are disclosing information about themselves changed over the past 10 years.<br />
- Just how much information does a mobile phone broadcast about its owner.<br />
- How easy it is nowadays for a detective to find out anything about you without leaving his or her desk.<br />
- What kind of databases are being put together, sold and used, and what kind of information can be found there.<br />
- A couple of interesting sites for information hunting.</p>
<p><object id="VideoPlayback" style="width: 400px; height: 326px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://video.google.com/googleplayer.swf?docid=3079242748023143842&amp;hl=ru&amp;fs=true" /><param name="allowfullscreen" value="true" /><embed id="VideoPlayback" style="width: 400px; height: 326px;" type="application/x-shockwave-flash" width="100" height="100" src="http://video.google.com/googleplayer.swf?docid=3079242748023143842&amp;hl=ru&amp;fs=true" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/anonymity-in-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tolua++ windows precompiled binary exe file download and more instructions on tolua++.</title>
		<link>http://www.codereactor.net/tolua-windows-precompiled-binary-exe-file-download-and-more-instructions-on-tolua/</link>
		<comments>http://www.codereactor.net/tolua-windows-precompiled-binary-exe-file-download-and-more-instructions-on-tolua/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 02:23:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=161</guid>
		<description><![CDATA[So, since the last post, I have started embedding lua and has had some minor problems. First I tried using luabind, which didn&#8217;t work at all for me. I didn&#8217;t want to include and build both luabind and boost (which it requires), and all of the precompiled solutions didn&#8217;t work either on my setup for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codereactor.net/wp-content/uploads/2010/10/logo.gif"><img class="alignleft size-full wp-image-172" title="logo" src="http://www.codereactor.net/wp-content/uploads/2010/10/logo.gif" alt="" width="128" height="128" /></a>So, since the last post, I have started embedding lua and has had some minor problems.</p>
<p>First I tried using luabind, which didn&#8217;t work at all for me. I didn&#8217;t want to include and build both luabind and boost (which it requires), and all of the precompiled solutions didn&#8217;t work either on my setup for different reasons, plus I just didn&#8217;t have time nor motivation to spend an hour trying to setup paths, projects, solutions, includes and so on for a library which should be precompiled.</p>
<p>So I thought screw luabind and I will go with tolua++. Which does almost the same thing but in a different way. Basically, luabind is like a library with a lot of macros, which you use to define your bindings in certain way in your code, and when the macros get expanded before compilation, the bindings start working. Tolua++ (and its predecessor tolua) on the other hand, only includes a very small runtime library, and most of the work is done before compilation by an external command line tool. It takes in special header files which you must write for your bindings and converts them to cpp files which you then include into your project like any other cpp file, and all the bindings are defined there. (This step is automated of course, you only define the special header and include the output file once).</p>
<p>tolua++ doesn&#8217;t require boost, which would mean less trouble compiling it, and also I thought that the exe file itself would be just downloadable precompiled.</p>
<p>However it wasn&#8217;t. But now after some time figuring out the compilation routine, I have compiled it and thought that I can put it out here for everyone who wants to save an hour or so by just fetching the file which should have been available from the author&#8217;s site from the beginning.</p>
<p>Anyways, here is the binary. It is for win32 and is tolua++ 1.0.93:</p>
<p><a href="/files/tolua++.zip" target="_blank">tolua++ 1.0.93 compiled binary (exe)</a>.</p>
<p>When compiling this, I have had a great help from this guide: <a href="http://lua-users.org/wiki/CompilingToluappWithoutScons">http://lua-users.org/wiki/CompilingToluappWithoutScons</a></p>
<p>Although some things in that guide seemed to be incorrect, so here is my modified version: <a href="http://www.codereactor.net/?p=163">Tolua++ compilation guide</a>.</p>
<p>As for actually using the tolua++, here is another awesome guide which should get you started: <a href="http://www.icynorth.com/forums/viewtopic.php?t=301">http://www.icynorth.com/forums/viewtopic.php?t=301</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/tolua-windows-precompiled-binary-exe-file-download-and-more-instructions-on-tolua/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling Tolua++ 1.0.93 without SCons (updated)</title>
		<link>http://www.codereactor.net/compiling-tolua-1-0-93-without-scons-updated/</link>
		<comments>http://www.codereactor.net/compiling-tolua-1-0-93-without-scons-updated/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 02:22:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=163</guid>
		<description><![CDATA[This guide is based on the http://lua-users.org/wiki/CompilingToluappWithoutScons I just have modified some things in the Visual Studio part, because in the original, the steps didn&#8217;t work for me. So, needless to say, most credit goes for the author of the original guide, I have just modified some stuff! I wanted to post this on the [...]]]></description>
			<content:encoded><![CDATA[<p>This guide is based on the http://lua-users.org/wiki/CompilingToluappWithoutScons<br />
I just have modified some things in the Visual Studio part, because in the original, the steps didn&#8217;t work for me.</p>
<p>So, needless to say, most credit goes for the author of the original guide, I have just modified some stuff!</p>
<p>I wanted to post this on the tolua++ site but they dont have a wiki.</p>
<p>The tolua++ INSTALL file lets you figure out how to compile it without SCons. Its easy enough, but I wanted to save the people the 5 ( err&#8230; 15 ) minutes they need to figure this out.</p>
<h3>Using GCC/Mingw</h3>
<p>I am using gcc 3.4.2, on a mingw installation. But I think this should work for most people, at least those using gcc, with minor modifications.</p>
<p>The commands used are :<br />
tolua++_1.0.5\src\lib&gt; gcc -shared -o tolua++.dll *.c<br />
\Lua502.dll -I..\..\include -I<br />
\include<br />
- This will create the dynamic library tolua++.dll in the src\lib directory.<br />
tolua++_1.0.5-1\src\lib&gt; gcc -c *.c  -I..\..\include -I<br />
\include<br />
tolua++_1.0.5-1\src\lib&gt; ar rcsv libtolua++.a *.o<br />
- This will create the static linking library in the src\lib dir.<br />
tolua++_1.0.5\src\bin&gt; gcc tolua.c toluabind.c -I..\..\include -I<br />
\include<br />
\Lua502.dll -L..\lib\ -ltolua++<br />
- This creates the tolua++ executable in the src\bin dir, assuming the libtolua++.a was created in the src\lib dir.</p>
<p>Note1: If you are linking against the lua static library instead of the dynamic library, replace<br />
\Lua502.dll with -L<br />
\lib -llua .</p>
<h3>Using Visual Studio 2003</h3>
<p><strong>Library (.DLL/.lib)</strong></p>
<p>Open the &#8220;File-&gt;New Project&#8221; menu. From the project types listbox, select &#8220;Visual C++ Projects-&gt;Win32&#8243;. From the Templates listbox, select &#8220;Win32 project&#8221;. For a project name, type in &#8220;tolua++&#8221;.</p>
<p>When the wizard opens, select &#8220;Application Settings&#8221; on the right hand side. Choose &#8220;DLL&#8221; and click &#8216;Finish&#8217;. If you want to compile to a static library, choose Static Library (.lib)</p>
<p>In the Solution Explorer right click on &#8220;source files&#8221; and select &#8220;Add-&gt;Existing Item&#8221;. Browse to the location of the tolua++\src\lib directory. Highlight all .c and .h files and add them to the project. You may also optionally want to add the tolua++.h file from the include directory into the &#8220;header files&#8221; folder.</p>
<p>Right click on the tolua++ project in the Solution Explorer and select &#8220;Properties&#8221;.</p>
<p>Under the &#8220;C/C++ -&gt; General&#8221; section select the &#8220;Additional include directories&#8221; option. Navigate to the location of your Lua include files.</p>
<p>Under the &#8220;C/C++ -&gt; Preprocessor&#8221; section add the following: TOLUA_API=extern __declspec(dllexport) Under the &#8220;C/C++ -&gt; Precompiled headers&#8221; section, turn off precompiled headers. Under the &#8220;Linker -&gt; General&#8221; section select the &#8220;additional library directories&#8221; option and navigate to the location of your Lua .lib library files. Under the &#8220;Linker -&gt; Input&#8221; section add lua.lib and lualib.lib (assuming those are your lua libraries).<br />
In more recent versions of lua there is just one library, for example &#8220;lua5.1.lib&#8221;. In that case, just include that.</p>
<p>Compiling the project should result in a tolua++.dll. or tolua++.lib, whichever you chose in the project settings.</p>
<p><strong>Executable (.exe)<br />
</strong></p>
<p>Now, to build the executable, you must first build the library. And even thou there is probably some way to do this using the .dll for of the library, it&#8217;s easier to do it with a static one. So before compiling the executable, first compile the library as a static library (not as .dll (project settings)), to get a proper .lib file.</p>
<p>To create tolua++.exe, open the &#8220;File-&gt;New Project&#8221; menu, select Visual C++-&gt; Win32 -&gt; Win32 console project. Add the files &#8220;tolua.c&#8221;, &#8220;toluabind.c&#8221; and &#8220;toluabind.h&#8221; to the project. (NOT toluabind_default.*)</p>
<p>Similarly to the previous step, add the lua .lib include directory (in project settings &#8211; linker &#8211; additional library directories) and the lib itself (project settings &#8211; linker &#8211; input (just write the library filename there (no path)))</p>
<p>If you have listened to my advice and linked the tolua++ library statically, don&#8217;t add anything in the &#8220;C/C++ -&gt; Preprocessor&#8221; section. If you went with dll, you will probably have to add<br />
&#8220;TOLUA_API=extern __declspec(dllimport)&#8221;</p>
<p>(NOTE: this is not the same line as in previous step. That one was with dllEXPORT).</p>
<p>Note that for v1.0.92, I had to remove the TOLUA_API that appears in toluabind.c:<br />
int TOLUA_API tolua_tolua_open (lua_State* tolua_S)<br />
becomes<br />
int tolua_tolua_open (lua_State* tolua_S)</p>
<p>Update: For 1.0.93 with static linking, I didn&#8217;t have to remove anything like that. So don&#8217;t worry about this unless you get compiler errors.</p>
<h3>Using Visual Studio 2005</h3>
<p>The same comments as above (for vs2003) generally apply, although some minor tweaks need to be made.</p>
<p>Note that, due to VS&#8217; poor c99 support, &#8216;toluabind.c&#8217; in the &#8220;EXE&#8221; build will not compile. There are many lines that look like:</p>
<p>&#8230; int top; top = lua_gettop(tolua_S); static unsigned char B[] = { &#8230;</p>
<p>These need to be changed to:</p>
<p>&#8230; int top = lua_gettop(tolua_S); static unsigned char B[] = { &#8230;</p>
<p>or similar.</p>
<p>Tested with vs2005 (no service packs) and tolua++ 1.0.91.</p>
<p>Codereactor update: Had no problems like this in VS2008, so maybe this is not the problem at all anymore.</p>
<p>You can also download the precompiled executable from here: <a href="/?p=161">tolua++.exe precompiled executable download</a>.</p>
<p>As for the precompiled library, I advice you not to bother. Tolua++ is just a couple of c files, just include them into the sources in your project, and forget about all that library inclusion hassle.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/compiling-tolua-1-0-93-without-scons-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedding a scripting language in your own C++ programs</title>
		<link>http://www.codereactor.net/embedding-scripts-in-c-programs/</link>
		<comments>http://www.codereactor.net/embedding-scripts-in-c-programs/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 21:48:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=136</guid>
		<description><![CDATA[One of my current projects has gained the critical mass complexity that can justify an embedding of a scripting language, so that some parts of the projects can be flexibly scripted instead of being hardcoded into the C++ code and thus require a time-consuming compilation every time anything changes. After reading a little about this, [...]]]></description>
			<content:encoded><![CDATA[<p>One of my current projects has gained the critical mass complexity that can justify an embedding of a scripting language, so that some parts of the projects can be flexibly scripted instead of being hardcoded into the C++ code and thus require a time-consuming compilation every time anything changes.</p>
<p>After reading a little about this, I found out that there are a lot of options, and most of them are really easy!</p>
<p>My first idea was to have two different programs, one in C++ and the other one in PHP (but any other multipurpose script language would suffice), and make them communicate with each other. The best choice for communication would the TCP/IP sockets, and interface could be coded pretty easily. Each function that needed to be exported, could easily be mapped through the network code. Two different programs could even be located on different machines and easily connect through the net.</p>
<p>This solution is possible, and is not that bad actually, but it can get pretty annoying to have two different programs to run and maintain.</p>
<p>So there I came upon the Real solution.</p>
<p>The two script embedding options I liked the most were Lua and JavaScript engine spidermonkey.</p>
<p>Lua is an opensource scripting language, which is very easy to embed and is being used worldwide mostly in games to script the gaming logic. It&#8217;s biggest advantage is the speed. By checking different benchmarks, I found out that lua code can be just around 30 times slower than c++ code, which is VERY fast for a scripting language. (For comparison, php is like 300-400 times slower, perl is something like 100-300 times, and Java approx. 10 times).</p>
<p>With this speed, some pretty complex calculations could be easily done in lua, instead of being hardcoded. The other advantage is that lua is semantically extensible, which means that it has very few features out of the box, but you could easily implement almost any paradigm or design pattern, whichever is most suitable for your application.</p>
<p>For example, there are no classes in their usual meaning in lua, they are instead &#8220;implemented&#8221; in code. When using lua, you are not only writing programs, but also sort of create your own language as you go.</p>
<p>As for embedding, with a small additional opensource library (of mostly macros) Luabind, binding functions and classes of your c++ program to lua becomes a piece of cake. It almost comes down to 1 extra line of code per mapped function, really smooth.</p>
<p>The second option I am considering is JavaScript spidermonkey, which is an embeddable JavaScript engine from Mozilla.</p>
<p>It would be great to have JavaScript in my project, since it&#8217;s awesomely flexible, wide-spread and very easy to code in, having a common syntax. Also, for most web developers, JavaScript is a language where you know every class and every function already.</p>
<p>The downside is the speed (approx. 300-400 times slower than native) and the complexity. Also, since the language itself is much more complex than barebone lua, embedding it to applications and mapping functions and classes from c++ can sometimes be tricky and bloated with type conversions and argument checks.</p>
<p>So this seems to be the pro way to do it, so that&#8217;s what I am gonna do.  (This time it&#8217;s gonna be lua but I am eager to try the spidermonkey some time also).</p>
<p>PS. It&#8217;s a pity I have overlooked this at first, but apparently, boost (which you should use most of the time anyway, cz its awesome) has built-in python bindings which work almost as easy (sometimes even easier) than luabind. So that&#8217;s a great alternative also, especially if you are a python fan.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/embedding-scripts-in-c-programs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 7 aero lag fix</title>
		<link>http://www.codereactor.net/windows-7-aero-lag-fix/</link>
		<comments>http://www.codereactor.net/windows-7-aero-lag-fix/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 15:34:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Offtopic]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=146</guid>
		<description><![CDATA[Windows 7 is great, but on my machine every once in a while, like after a couple of hours of working, the interface starts to lag. Nothing big, probably just 100 milliseconds or something, but it is noticeable, and especially when watching movies. Don&#8217;t really know what it is exactly, maybe something with drivers or [...]]]></description>
			<content:encoded><![CDATA[<p>Windows 7 is great, but on my machine every once in a while, like after a couple of hours of working, the interface starts to lag. Nothing big, probably just 100 milliseconds or something, but it is noticeable, and especially when watching movies. Don&#8217;t really know what it is exactly, maybe something with drivers or some program that slows it down, but there are numerous reports of this out there on the internet. And this thing is really annoying, because once it has started, EVERYTHING is lagging, all the windows and everything that happens on the screen.</p>
<p>This has nothing to do with too little memory or some process running in background. The lag would appear even when processor usage was on 0-5 percent.</p>
<p>So, basically, the workaround for this: once it starts to lag, switch a window with Windows+Tab button. (To open that 3D taskswitcher that came in Vista). Once you have done that, the lag is gone.</p>
<p>It is sure strange, seems like there is some bug that starts when something gets overrun, and the 3D task switcher resets it to make everything run normally again.</p>
<p>This isn&#8217;t really a fix, just a workaround, but searching the internets gave me nothing, and this solution is still viable. So here you go people, if somebody stumbles across this article with the same lag problem, there you have a solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/windows-7-aero-lag-fix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yahoo Pipes</title>
		<link>http://www.codereactor.net/yahoo-pipes/</link>
		<comments>http://www.codereactor.net/yahoo-pipes/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 22:00:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://www.sterlingoff.nu/?p=127</guid>
		<description><![CDATA[*** The pipes didn&#8217;t come out yesterday, so those of you who have already heard about them, can simply skip this post. But those who didn&#8217;t, are about to find out something wonderful! The pipes are a web service from Yahoo and can be accessed by going to http://pipes.yahoo.com/pipes/ As an example of what it [...]]]></description>
			<content:encoded><![CDATA[<p>*** The pipes didn&#8217;t come out yesterday, so those of you who have already heard about them, can simply skip this post.</p>
<p>But those who didn&#8217;t, are about to find out something wonderful!</p>
<p>The pipes are a web service from Yahoo and can be accessed by going to <a href="http://pipes.yahoo.com/pipes/">http://pipes.yahoo.com/pipes/</a></p>
<p>As an example of what it can do, let&#8217;s take today&#8217;s featured pipe: eBay price watch. Apparently, it gives you information about certain items from ebay, found by certain keywords that lie in a certain price range.</p>
<p>Without any tools at all, finding this information would require going to eBay, searching for items, sorting, finding the ones you want, and repeating that over and over again. If you are decent programmer, you could easily make a PHP script or something that does it for you: goes to eBay, fetches a page using a search request, parses it and so on. It is doable, but is it worth the trouble?</p>
<p>Well with yahoo pipes a script like that takes no more than 10 minutes to create! It is all because instead of writing code, you are combining structural blocks that process information in certain ways, which can include search/replace, regexps, combining functions, well basically any kind of aggregation you could possibly imagine.</p>
<p>Yahoo pipes are based on RSS, so the most used output method from the pipe is an RSS channel, which, if we are talking about the eBay example, could be imported into your favorite RSS reader.</p>
<p>Basically any data from any webpage, RSS channel or any url can be inserted into a yahoo pipe and converted to the format you want. Several sources of data can be used, records can be combined, removed, parsed, and so on, with limitless possibilities. And, what is more important, all the above is done simply, fast and visually, which, besides the development speed, also gives you a lot of room for experimentation and creativity.</p>
<p>(And no, I don&#8217;t work for Yahoo, it&#8217;s just that this service is really a great contribution for human kind <img src='http://www.codereactor.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> )</p>
<p>And I haven&#8217;t even told you the best part: Yahoo pipes support information io in JSON and if I remember correctly, even PHP-serialized, which, combined with its possibility to fetch anything that has a url, effectively means that you can create your own modules for pipes that can do anything that pipes cannot do already, making the service omnipotent.</p>
<p>If nothing else, it is a great way to test new ideas without having to write a single line of code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/yahoo-pipes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

