You are hereDevelopment
Development
Articles related to programming and software development
Visual C++.NET 2003 and Broken Managed Assemblies
This is some really annoying bug in Visual Studio .NET 2003 (SP 1), took me two hours of my life: If the intermediate directory is set to something like ".obj/$(ConfigurationName)", the Assembly created will be broken, since it "does not contain a CLI header" - so the error message. It seems something is going completly wrong during compilation, since the dll is only 3 to 4 kB in size. If you omit the leading dot and set the intermediate directory to "obj/$(ConfigurationName)", it works.
std::clock(), threading, and Linux
I had a strange experience with the boost::timer class the other day, since it never elapsed within a certain thread. As it turns out, this was because std::clock() itself doesn't tick but returns the same value over and over again - a value that probably indicates the time the tread was started. The solution is rather simple: I implemented the boost::timer interface based upon boost::xtime from the boost threading library like this:
XMLRPC value types and C++
A while ago, I was looking for a C/C++ XMLRPC client implementation. However, for some reason or another, I was unsatisfied with the recent implementations, which mostly seem utterly complex for my purposes. That's why I decided to roll out my own. While the XML building and parsing is more or less straight forward (although there's too much redundancy and unneccessary tags in the spec for my taste), implementing the possible value types made me scratch my head. The XMLRPC protocol supports a set of data types: integer, string, double etc., but also an array or a struct. Integer and double are native types, string is either a char pointer or a class. How this should be put within one class? My first sketch introduced a quite complex model with an impressing inheritence chain, but then boost::variant came to the rescue:
Using scriptaculous slider with two handles
Since version 1.6 the slider widget coming with the script.actulo.us javascript library can have more than one handle. This for example allows something similar to the Amazon diamond search. I did it here. However, the script.aculo.us documentation isn't up to date currently, so here's how you do it.
A triangle with rounded corners in C#
For one of my projects I needed to draw triangles with rounded egdes, and since I didn't found anything about this topic elsewhere, I had to figure it out by myself. Luckily no mathematics is needed, except the Pythagorean theorem. So here'S how I did it, complete with a sample implementation using C#.
To make things easier, I started with a right-angled triangle where the two sides forming the right angle are vertical and horizontal. This makes applying a rounded corner for the right angle easy, since it is a common problem known from drawing rounded rectangles. You'll find examples for this all over the net. I instead will discuss, how to round the two other edges, which both form an angle of 45 degrees.
A 64 bit integer for PHP
thegeek misses a 64 bit integer for PHP (German), since he uses a bitmask with more then 32 options. Here's a proposal, how to deal with this problem by splitting a float into two integers:
<?php
define("BIGINT_DIVIDER", 0x7fffffff + 1);
function split2Int(&$upper, &$lower, $value) {
$lower = intval($value % BIGINT_DIVIDER);
$upper = intval(($value - $lower) / BIGINT_DIVIDER);
}
function bigInt2float($upper, $lower) {
return $upper * BIGINT_DIVIDER + $lower;
}
?>split2Int puts the upper 32 bits into $upper and the lower 32 bits into $lower. Binary operations can now be performed on both the ints. Afterwards, the result in converted to a float using bigInt2float(). I also wrapped up this stuff into a little class. You can download it here.
Microformats: Prefering machines over people
Anybody ever took a look at the Datetime Design Pattern at Microformats.org (via Georg Bauer (German))? It goes like this:
<abbr class="foo" title="YYYY-MM-DDTHH:MM:SS+ZZ:ZZ">Date Time</abbr>
I think this is a misuse of the abbrevation tag - and worse: it's completly ignoring user experience. Most of nowadays browsers display the text of the title attribut when you hover over the abbrevation. Now imaging a user browsing your microformatted page. When he hovers over a date like - say - May 4th 1970, which is my birthday, he'll see a tooltip stating "1970-05-04T18:10:52+01:00". Doh!
Don't trust PHP_SELF
Sean Coates points out why $_SERVER["PHP_SELF"] must be considered unsafe. You should never use it without at least converting it to entities:
<?php
print htmlentities($_SERVER['PHP_SELF']);
?>This offers me the chance to again repeat one of my mantras: Create a function for everything, at least when reading values from somewhere, even for something simple like retrieving the value of PHP_SELF. The reason is maintenance: If you haven't previously validated the value of PHP_SELF there will be only one place to change, instead of checking all your code.
Large-Scale C++ Software Design
Following up on a comment from Udi Dahan about physical design Len Holgate points out that
If you're working in C++ and you haven't read Large-Scale C++ Software Design (APC) by John Lakos then you really should.
This is definitly true. John Lakos' book - beeing as far as I know the only one on the topic - is a must-read for each C++ developer.
Len is using Lakos' book as an argument against my post about C++ still beeing needed? and further states:
You have to actively manage your dependencies all the time, no matter what language you're working in. If you don't do it in C++ you can end up in a hell of slow compiles and horribly entwined code that all needs to be rebuilt if you ever change one class. If you do it right you rebuild just what needs to be built and you depend on just what you need, and no more.
Again: true. However, each project contains some very fundamental libraries, nearly all other packages depend on. A custom string class comes to mind ;-), but there are other. Let me tell you a little bit about the application I'm developing at work to get things clear.
Is C++ still needed?
Christopher Baus is reasoning about why C++ is falling out of favor:
In domains where low level access is critical, developers are going for C. If developers can live with higher level abstractions, then they are skipping straight to Java or Python or Ruby or PHP, and by passing C++ altogether. C++ is getting squeezed out in the middle.
I think he's right. If you're doing large scale business applications, like I do on work, C++ definitly is not the language of choice. Some reasons:

