Eclipse-CDT: Base class ” not in include paths for current project

eclipseDon’t you just hate weird things like this? You have a nice little project in Eclipse, it’s all is working fine, auto-complete, build, everything.


When you try to add a new class using the File -> New -> Class menu, you get this error:

Base class 'myclassname' not in include paths for current project.


This one is easy to fix.

Read moreEclipse-CDT: Base class ” not in include paths for current project

Bitwise Operators – Free Guide

Bitwise OperatorsI have an exciting new eGuide available.

Most of this info is available in various places on my site, but I’ve collated it all together in one document, and updated it, so it’s easier for you to use.

What does it cover?

It’s a no-jargon guide to the four bitwise operators in C (AND, OR, XOR, NOT).

Not only does it walk you through exactly how each one works, with examples, it also provides explanations of how they would be used in programming and (as if that wasn’t enough), there’s a handy quick-start guide at the end which you can refer to so you know exactly when to use each operator and why.

It’s all written in a no-nonsense, easy to read format, that makes programming the joy it should be.

Hurrah to that, I say.




Understanding Pointers (with Lego) Part 1

Ahhh pointers.

I’ve been wanting to write a series of posts on pointers for a long time. When I’ve finished, I’ll upload a complete PDF eGuide. In the meantime, enjoy 🙂


A concept that some programmers avoid through fear, others abuse through ignorance, and yet others manage to use with grace and efficiency.

Every programmer who does more than dabble in C and C++ needs to understand this subject. Properly.

This is Part 1 of a multi-part series, and there will be a lovely quiz at the end, which I expect you will all get 100% on after reading my posts, right?

Let’s crack on.

Read moreUnderstanding Pointers (with Lego) Part 1

Unions in C

Unions – ew.

As primarily a C++ programmer, I used to shy away from code that contained this kind of black magic. However, unions are actually very cool things and are really not that scary or weird.

A union is basically a variable. But instead of being an int, or a float, or a double, a union can actually be any one of these things at a given point in time.

What? That doesn’t make any sense!

Wait – let me illustrate with an example.

The code below contains a union declaration at the top. Unions are declared just like structs, but instead of containing ALL the variables listed, a union only contains enough space for the largest one.

So in my example, where the union contains an int and a char – how big do you think will it be?

That’s right, it will be a single variable the same size as an int, because an int is larger than a char.

Storing and accessing union data is done just like it is with a struct:

#include <stdio.h>

int main()
    union ascii
        int number;
        char symbol;
    } a;

    /* Incoming data - could come from a variety of sources: */

    a.symbol = 'x';
    a.number = 120; 

    /* output last type in (int) */
    printf("Variable a is set to %d\n", a.number);

    return 0;

Okaaay… but how do you know what it is when it can be multiple things?

Good question. You can’t actually tell what is inside a union, but the rule is that whatever you put in last, will be what you get out, and it is YOUR responsibility to remember what it was.

The best way to do this is with a variable that you update to contain the correct type (use an enum of INT, FLOAT, etc.)

If you access a union using a type that isn’t the same as the one last stored, what you get back is undefined.

Unions are really useful when you want to save storage space (especially good in embedded programming), or if you are receiving data that may arrive in different types (but which is essentially being used for the same purpose).

See? Not so scary after all.