Archive for the ‘C & C++’ Category

Event handling in C and C++

One of the most-occurring subpatterns I keep running into lately is an event-handling subpattern. I say subpattern because it is not a pattern in and of itself: it can be part of an observer pattern, a state machine, or of any other pattern in which objects that have neither an “is-a” nor an explicit “has-a” [...]

Read the rest of this entry »

Binary Search

While going through some old code, for another article I’m writing that will come up on the blog, I came across an implementation of binary search in C. While the implementation itself was certainly OK, it wasn’t exactly a general-purpose implementation, so I thought I’d write one and put it on the C++ for the [...]

Read the rest of this entry »

Lock-Poor Stack

The following is the complete code of a lock-poor stack in C/C++: it’s mostly C but it uses Relacy for testing, so the atomics are implemented in C++. With a little work, you can turn this into a complete C implementation without depending on relacy. I wrote in while writing an article that will soon [...]

Read the rest of this entry »

The answer to the quiz in episode 7 of C++ for the self-taught

I know you must have been aching for the response to the quiz from three weeks ago. If you haven’t thought of your own answer yet, go back to the code and have another look. Try running it through a compiler with all the warnings turned on – it might tell you what the bug [...]

Read the rest of this entry »

Error handling in C

One of the things I do as a analyst-programmer is write software – that would be the “programmer” part. I usually do that in C++ but, sometimes, when the facilities of C++ aren’t available (e.g. no exception handling and no RTTI) C becomes a more obvious choice. When that happens, RTTI is not the thing [...]

Read the rest of this entry »

Badly defined semantics

There is probably nothing worse than badly defined semantics: functions that might (or might not) take ownership of the object you pass to them can be a serious maintenance headache.

Read the rest of this entry »

The Importance of Proof-Of-Concepts

Any problem is an invitation to find a solution. Any solution – at least in my line of work – is an amalgam of concrete implementations of abstract concepts. Each of those implementations may or may not meet the requirements just like any of those concepts may or may not be the right one for [...]

Read the rest of this entry »

Binary Compatibility

When writing library code, one of the snares to watch out for is binary compatibility. I have already talked about the dangers of breaking binary – and API – compatibility but I had neither defined what binary compatibility is, now how to prevent breaking it. In this post, I will do both – and I [...]

Read the rest of this entry »

The Danger of Breaking Changes

Xerces-C is without a doubt one of the most popular DOM implementations in C++ (and its Java sibling undoubtedly the most popular implementation for Java). As with any project that lives under the banner of the Apache Foundation the project is managed using a meritocracy-style project management scheme and has been, quite successfully, for the [...]

Read the rest of this entry »

Naming conventions and name mangling

In C++, any name that starts with and underscore followed by an uppercase letter and any name that contains two consecutive underscores is reserved for any use [lib.global.names] and any name that begins with an underscore is reserved in the global namespace. The intent for this, as explained by several people on comp.std.c++ is to [...]

Read the rest of this entry »
 
This blog is monetized using Are-PayPal WP Plugin