All posts by tolon

Beware setlocale() in Visual C++ 2012 onwards!

My new article in ACCU’s CVu magazine describes how investigating a crash in a popular open source library led to the discovery of a change in behaviour in the C runtime library implementation that could have a significant detrimental impact on applications using C runtime locales across multiple threads that are compiled with Visual C++ 2012 & 2013 – http://accu.org/var/uploads/journals/CVu264.pdf#page=12

Transporting SDO_GEOMETRY objects across an Oracle DBLINK in PLSQL

At my work we have a system that generally speaking consists of two Oracle 10g databases, the ‘SpatialDB’ and the ‘AppDB’. The SpatialDB holds a multi-gigabyte set of static national road-network geometry data and the AppDB holds the dynamic runtime data. A database link is defined in the AppDB so that it can query the SpatialDB and invoke stored procedures.

Generally what happens is that an action somewhere in the system (user interaction, external system communications, etc.), will result in something happening in the database.

In this case a package method in the AppDB needed to obtain a geometry from the SpatialDB. Surprisingly, this turned out to be a quite a difficult thing to achieve. It seems that along with cursors, LOBs and objects in general, an SDO_GEOMETRY cannot be transported across a database link as an out parameter of a package method. The following is a summary of the methods I discovered for overcoming this.

Continue reading Transporting SDO_GEOMETRY objects across an Oracle DBLINK in PLSQL

Lightweight Cooperative Multitasking with Boost.Context

I’m writing this in response to Kenny Kerr’s article Lightweight Cooperative Multitasking with C++ in the August 2012 issue of MSDN Magazine, in which Kenny describes a method of implementing cooperative multitasking in C++.

What is Cooperative Multitasking?

This is a method of achieving concurrency in an application without using multiple threads. The basic idea is that you can have multiple tasks running on just a single thread. Now of course only one of these tasks can be running at any one time, so each task must perform some work and then explicitly yield to another task.

Ideally whatever method is used for beginning tasks and yielding should automatically provide a separate context for each task. That is, each task should have its own stack and register data.

Why Kenny’s Article is Cool

Continue reading Lightweight Cooperative Multitasking with Boost.Context

Reading an In-Memory SQLite Database

I’m currently working on a utility to improve upon the basic Error Lookup utility found in Microsoft Visual Studio. I am trying to improve it by collating all the error codes and messages found in the Microsoft Platform SDK into a database, which can be accessed and queried in a similar way to the existing utility, but with a extra bells and whistles (think free-text search, partial code matching, etc.). To make distribution of the utility easier, I decided to try embedding my error database into the executable file, which was straightforward. Using the database however required a bit more work, which I am presenting here in the hope that others will find it useful.

Continue reading Reading an In-Memory SQLite Database

Recent Lessons

I’ve recently picked up TolonSpellCheckLib and Tolon NoteKeeper again after a long time away from it. I’m doing a lot of PL/SQL and testing at work at the moment, so I need to quench my thirst for C++ with a bit of ‘extra-curricular’ development.

Since last building my code in 2009 I have moved to Windows 7 64-bit and a new hard drive, so I was anticipating a fair bit of messing around in order to get a usable source/build tree again. As it turns out it wasn’t too bad, but I thought I would record a few useful notes on lessons I have learned from this process.

Continue reading Recent Lessons

Integrating your application with Enchant – Part 2

Enchanté

Welcome to the second article exploring how to integrate the spell checking library Enchant into your Visual C++ applications.

I will be using this library with my freeware program NoteKeeper, which I am currently maintaining/developing in two versions of Visual C++.

  • Visual C++ 6 SP6 with STLPort 5.1.5, Multithreaded DLL
    (cl.exe v12.00.8804, link.exe v6.00.8447)
  • Visual C++ 9 SP1, Multithreaded DLL
    (cl.exe v15.00.30729.01, link.exe v9.00.30729.01)

Continue reading Integrating your application with Enchant – Part 2