CodeBlocks 12.11 Update (Final, for Now)

I had promised in my CodeBlocks 12.11 Update (Reminder) post to let you know about update information for the CodeBlocks 12.11 version. Because I received only a few messages from interested readers and all but one of them have said that the 10.05 posts are working fine for them, I’ve decided not to provide a new series of posts at this time. Of course, it may be that other people using C++ All-In-One Desk Reference For Dummies will experience problems and I’ll need to provide those updates after all. Nothing is ever final here—only final until it needs to change.

My main goal is to ensure that readers have everything needed to use my book successfully. At the moment, it appears that they do, but please don’t feel your input isn’t valuable to me. Always feel free to write me about issues you have with my books. Whenever possible, I’ll provide the information you need to use my books successfully right here on this blog so you can access the information whenever you need it. You should always check my blog as your first resource for answering questions.

If there is any additional input on this particular issue, please feel free to write me at If I later find that a series of 12.11 posts is necessary, I’ll be more than happy to write them. In the meantime, keep those e-mails coming! I really enjoy hearing from you .


CodeBlocks 12.11 Update (Reminder)

Last week I wrote a post entitled, “CodeBlocks 12.11 Update.” So far, I’ve received only a few e-mails about the update. However, I’m still receiving e-mail on the topic and I want to be sure everyone is heard. If you haven’t had a chance to write me yet about the CodeBlocks 12.11 update and whether it affects you when working with my book, please contact me at

Part of the reason I ask about these updates is that I like to track how many people are using a particular update with my books. It helps me build a picture of my readers so that I can serve their needs better. The information also helps me understand how quickly people update particular products so that I have a better idea of when to ask publishers about a book update.

Often, I’m not successful in obtaining an update from the publisher unless there is a compelling reason to write one. That’s where you come in. Readers have provided me with more good reasons to provide an update than any other source I use for determining when one is needed. Your input really does matter, so please keep those e-mails coming. I plan to provide a post that will let you know whether I’ll write update posts for CodeBlocks 12.11 for C++ All-In-One Desk Reference For Dummies next week Monday.

CodeBlocks 12.11 Update

A number of readers have recently begun writing me about issues with CodeBlocks 12.11 with the example code for my book. I originally wrote C++ All-In-One Desk Reference For Dummies around the 8.02 release of CodeBlocks, which is still available at Just look halfway down the page and you’ll find the download you need. I still highly recommend that you use the 8.02 release with the book, simply because the newer product versions introduce compatibility issues that make it necessary for you to modify the example code in certain ways.

However, I also understand your desire to work with the latest version of the product. That’s why I wrote a series of posts about the 10.05 release of CodeBlocks and what you would need to do to make it work with the examples. Unfortunately, another group of readers has complained that the instructions are too hard to follow. The fix, of course, is to use the 8.02 release if you find that the 10.05 release isn’t working well for you. There isn’t much else I can do at this point to make things easier (although, I’m always open to your ideas).

What I’d like to know is how many readers are actually using the 12.11 release and whether the instructions for the 10.05 release also work in this case. My initial take is that there are at least a few readers who have found they need version 12.11-specific instructions, which would mean another series of blog posts to address changes to the examples. I’d start with the original code and wouldn’t force you to make multiple updates. As you might imagine, testing every example in the book and writing an update procedure for it (if necessary) will take time, so I want to be sure that there is interest in this series of posts.

If you have an opinion on this topic, please let me know. I’d like to determine how much interest there is in a series of posts that describe code changes needed to make my book work with the 12.11 update. Please contact me at with your ideas and questions.


Getting CodeBlocks to Work – An Update

Quite a while ago, at least in computer technology terms, I wrote the Getting CodeBlocks to Work post to make it easier for readers to obtain a good copy of CodeBlocks to use with C++ All-In-One Desk Reference For Dummies. It seems that some of the information I provided at that time has become outdated.

While the link still works fine, some of the other links may not. A reader recently pointed out that the automated installer location has changed. When you go to the original automated installer site, you now see a number of links, including one listed as Download mingw-get-inst-20111118.exe (591.9 kb ).

Clicking the new link will automatically start a download of the latest automated installer. When the download is complete, you can install your copy of CodeBlocks. Another link to the same download is The point is that there is a download that will work with your system, no matter what system you’re using.

If anyone encounters a problem with these latest downloads, please let me know at I want to be certain that you have a great learning experience when working with my books.


Using Boost 1.48.0 with CodeBlocks 10.05

Whenever you work with the material in C++ All-In-One Desk Reference For Dummies it’s always best to use the version of the software that the book is written to use. For the current version of the book, that means using CodeBlocks 8.02 and Boost 1.39.0. However, some readers really do want to use the most current version of the software and I can understand why they’d want to do so. That’s why I wrote a series of posts discussing the use of CodeBlocks 10.05:



Part 8 of this series of posts says that I’ve tested the book’s code with a combination of CodeBlocks 10.05 and Boost 1.47.0. Since that time, the makers of Boost have come out with another version of the product and a few readers have questioned me about it. I’ve verified that the compiler does in fact work with Boost 1.48.0 as well. So, you can use CodeBlocks 10.05 and Boost 1.48.0 together.

That said, some of the procedures found in the book for performing tasks such as building the tools are unlikely to work without modification. For example, on page 679 I tell you how to build Boost Jam. This tool no longer exists in 1.48.0, so naturally that directory is missing and the procedure won’t work. If you plan to use Boost 1.48.0, you’ll need to modify the procedures in the book to match your setup. I’ll rewrite these procedures to work with the latest version of the software during the next book update.

There is one important change you need to know about in order to successfully build the applications using Boost 1.48.0. Look on page 693 and you see a procedure for adding the Boost directory to the search directories list. You must change the directory to match the installation directory for Boost 1.48.0. The book assumes you’re using Boost 1.39.0 and uses that directory in the procedure. Other than this change, the example should work just fine.

If anyone does run across a problem using Boost 1.48.0, I’d love to know about it. Please contact me at with details about the problem you’re having and I’ll do my best to solve it.


Mind Boggling Questions in C++

I constantly tell readers they need to view my books as a starting point, rather than the end of their education on a particular subject. This sentiment holds true for C++ All-In-One Desk Reference For Dummies as it does for all of my books. When you read this book, you get a really good start with C++. By the time you’re finished, you can create some useful applications and you know enough about the CodeBlocks IDE to use it effectively. Fortunately, there are many places online to expand when it comes to C++ and I ran across one of them today in an article entitled, “Amusing C++.” The title, more than anything else, caught my attention. What, after all, could be amusing about C++?

This is one of those sorts of articles I wish I had thought to write myself. The author, Vasily Starostin, has a unique perspective about C++ and some of the issues you could face when working with it. More importantly, he uncovers some interesting compatibility issues between compilers, all the while having fun with the C++ language.

These sorts of mind boggling questions force even professional developers to think about the language and how it works. It may seem as if a language specification is solid, but then you see that there are gaps in how the specification is put together and that there is room in the standards for unique vendor implementations. Working with unique implementations can lead to innovation, but it can also lead to all sorts of compatibility issues when you need to move your application from one product to another.

After you’ve completed reading my book, make sure you continue on with online resources. Of course, the place that you should look first for issues related to this book (and some general interest C++ topics) is the C++ All-in-One for Dummies category on this blog. It’s a shame that this particular Dummies book doesn’t include the Parts of Tens feature that is found in other Dummies books. However, here are ten places you can look for C++ materials and examples:

Where do you get additional information about C++? What sorts of information do you look for on these sites? Let me know at


Passing By Value Versus By Reference

A number of readers have written me about the examples that use pointers in the book. One of the most common questions comes from the example on page 149 of C++ All-In-One Desk Reference For Dummies. In this example, the application contains a function that accepts an argument by reference. The use of a reference seems to have many people confused and this post will hopefully clear the issue up.

The first thing you need to understand is that there isn’t any magic going on here. The process for working with functions remains constant in C++. When you call any function with an argument, the application creates memory to hold the argument. The memory is local to that function. When the function ends, the memory is released. What the memory holds, now that changes.

Think of the memory as a box. This box has an address that points to it. When you work with a pointer, you’re working with the address. On the other hand, when you work with the value, you’re working with the content pointed to by the pointer, or the contents of the box. Whether the box the function receives contains a pointer or the value depends on how you write the function and what you pass to it from the caller.

Now, let’s look at an example so that you can better understand what’s going on.  This example will do the same thing to the number each time, but using different techniques: by value, using a pointer, and by reference.

#include <iostream>
using namespace std;
void MessMeUpA(int myparam)
    myparam = myparam * 2 + 10;
void MessMeUpB(int* myparam)
    // Obtain the current value.
    int currentValue = *myparam;
    // Perform the required math.
    currentValue = currentValue * 2 + 10;
    // Save the result.
    *myparam = currentValue;
void MessMeUpC(int &myparam)
    myparam = myparam * 2 + 10;
int main()
    // Call by value.
    int mynumber = 30;
    cout << "By Value: " << mynumber << endl;
    // Call using a pointer.
    mynumber = 30;
    cout << "By Pointer: " << mynumber << endl;
    // Call using a reference.
    mynumber = 30;
    cout << "By Reference: " << mynumber << endl;
    return 0;

You may notice that part of this example comes directly from page 149. If you run this example, you’ll see this output:


When you pass the data by value, you’re passing the information, not a pointer to the information. As a result, MessMeUpA() receives a value of 30. It doesn’t receive a pointer to the initial variable, nor does it obtain a reference to the initial variable. As a result, when the application performs the calculation, the result is thrown away.

When the application calls MessMeUpB(), it provides a pointer to the variable. However, the pointer isn’t a value. As a result, you move the value pointed to by the pointer into a local variable, perform the required math, and then move the value back into the original pointer. As a consequence, the original value is altered to 70.

Finally, when the application calls MessMeUpC(), the function obtains a reference to the original memory location. When the function performs the math, it’s actually using the original value as pointed to by the reference, which means that this is a kind of pointer, just not passed from the caller. The changes made in MessMeUpC() are reflected in the original value because you’re using a pointer to that value and not a copy of the value in local memory.

I highly recommend that anyone trying to understand how code works use the debugger to trace through that code. It’s instructive to look at each of the functions to see how they look. Place a breakpoint in each of the functions and then start the debugger. Open the Watches window, if necessary, by choosing Debug | Debugging Windows | Watches. Here is the view of the Watches window when calling MessMeUpA().


What you see here is a function argument—an integer that contains the value of 30. Now, let’s look at MessMeUpB().


In this case, you see a local variable, currentValue, that contains the updated value and a pointer to the variable used by the caller in myparam. The pointer gives you access to the value held by the caller and allows you to change it. Finally, let’s look at MessMeUpC().


Look at the function argument, myparam. The debugger is giving you a valuable insight here. See the address provided with the variable? Match that address to the pointer provided to MessMeUpB() and you’ll see that they’re the same. The reference is simply another sort of pointer, but one that gives you direct access to the memory without having to go through the extra steps required by pointers. The debugger even shows you that the current value of that memory is 30 (the math hasn’t been performed as of yet).

A function argument is simply a box that holds either a value or a pointer. Whether that pointer is an actual pointer or a reference depends on how you write you code. That’s the point of the example. Pointers don’t have to be mysterious or hardthey’re simply an address for an area of memory (a box if you will) that holds a specific value. Please let me know if you have any questions about this issue at


Debugging a CodeBlocks Application with Command Line Arguments

Most application environments provide a means of setting command line arguments and CodeBlocks is no exception. The example shown in Listing 4-12 on page 107 of C++ All-In-One Desk Reference For Dummies requires that you set command line arguments in order to see anything but the barest output from the debugger. This post discusses the requirements for setting command line arguments for debugging purposes.

Let’s begin with the example without any configuration. Every application has one command line argument—the path and application executable name. So, when you run the example shown in Listing 4-12 you’ll see the path and executable name as a minimum, as shown here.


If you run this example, you may see a different path, but the command line executable should be the same. The point is that you see at least one argument as output. However, most people will want to test their applications using more than one argument. In order to do this, you must pass command line arguments to the application. The following steps tell how to perform this task.


  1. Choose Project | Set Program’s Arguments. You’ll see the Select Target dialog box shown here.
  2. Select Debug as the target, as shown in the figure.
  3. Type the arguments you want to use, such as Hello Goodbye, in the Program Arguments field and click OK. The IDE is now set to provide command line arguments to the application when you’re using the specified target, which is Debug in this case.

To see how this works, set a breakpoint at the line that reads (you’ll find a discussion of how to set breakpoints on page 375 of the book):

for (int index=0; index < argc; index++)

You also want to create a watch that shows the command line arguments in action. In this case, you want to see the particular argument that the application is processing. Use these steps to set the watch.


  1. Choose Debug | Edit Watches. You’ll see the Edit Debugger Watches dialog box shown here.
  2. Click Add. You’ll see the Add Watch dialog box shown here.
  3. Type argv[index] and click OK. You’ll see the new watch added to the Edit Debugger Watches dialog box.
  4. Click OK. The new watch is ready for use.

You’re ready to test out the new setup. Choose Debug | Start or press F8. The debugger will start. If you don’t see the Watches window, choose Debug | Debugging Windows | Watches. Click Next Line and you’ll see the first command line argument as shown here.


Notice that the value of index is in red because it has changed to 0. In this case, argc contains 3 arguments (including the first one that you’re seeing now) and that argument is in argv, which is pointed to at the memory address shown. The argument at that first index value is the path and command line executable name, just as expected.

Click Next Line twice. Now you’ll see the second argument, as shown here.


If you followed the instructions earlier, you should be seeing Hello as the second argument as well. Click Run and you’ll see the output shown here.


Testing for command line arguments in a CodeBlocks application consists of telling the IDE what to pass in the Select Target dialog box and then setting the correct watches so that you can see how the command line arguments work. Let me know if you have any questions about this process at


Using CodeBlocks 10.05 – Part 8

This should be the next to the last post in this long running series. In the previous post, Using CodeBlocks 10.05 – Part 7, I was able to cover up to the end of Book V of C++ All-In-One Desk Reference For Dummies. This post begins with Book VI Chapter 1. I’m hoping to wrap up the coding differences for CodeBlocks 10.05 in the next post. You can find a complete list of these posts in the C++ All-in-One for Dummies category archive.

On page 638, you’ll find an example of the Functors category of the standard library. Likewise, on page 649 you find an example for working with temporary buffers. Neither example will compile in CodeBlocks 10.05 until you add another #include:

#include <algorithm>

On page 640, you’ll find a hash example. It compiles just fine, but you’ll receive this rather ominous sounding warning:


#warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.

It’s safe to ignore the warning for this edition of the book. In fact, you may see a number of these warningsall of which are safe to ignore for the time being. The example will run as before. The purpose of the warning it to tell you that a code update is necessary to keep pace with changes to the C++ libraries. I’ll be updating the code to use newer headers in the next edition of the book.

On page 641, you’ll find the hash map example, which won’t compile in CodeBlocks 10.05. This example requires the addition of another #include statement:

#include <string.h>

On page 647, you’ll find an example for using the random number generator. This example requires that you add the following two #include statements:

#include <time.h>
#include <stdlib.h>

On page 663, you’ll find an example for performing template specialization. You’ll need to add the following #include for this example:

#include <limits>

I tried the Boost examples in Book VI Chapters 3 and 4 using the latest version as of this writing (version 1.47.0). It appears to work fine with CodeBlocks 10.05 and the source code in the book. However, I’d like to hear about any problems that anyone has encountered using it.

If you encounter any other problems with Book VI, please be sure to let me know. In the next post I’ll start
with Book VII Chapter 1. In the meantime, keep those e-mails coming to

Using CodeBlocks 10.05 – Part 7

In the previous post, Using CodeBlocks 10.05 – Part 6, I was able to cover up to the end of Book IV of C++ All-In-One Desk Reference For Dummies. This post begins with Book V Chapter 1. I’m hoping to wrap up the coding differences for CodeBlocks 10.05 soon. You can find a complete list of these posts in the C++ All-in-One for Dummies category archive.

All of the projects in Book V Chapter 1 compile cleanly and work fine in CodeBlocks 10.05. Some readers have complained about the use of .DAT as a file extension. You can change it to .TXT if desired. A few others report problems with Windows Vista and Windows 7 using the root directory for file storagethere isn’t any problem with using a different directory to hold the test files as long as you use the same directory consistently. For example, you might want to change the directory to C:/Author/MyFile.dat.

There is a sidebar on page 585 (Book V Chapter 2) that tells how to get the working directory. This example appears in the \Author\BookV\Chapter02\GetWorkingDirectory folder. It won’t currently compile because it’s missing an #include for stdlib.h. The code should actually look like this:

#include <iostream>
#include <direct.h>
#include <stdlib.h>
using namespace std;
int main()
    char CurrentPath[_MAX_PATH];
    getcwd(CurrentPath, _MAX_PATH);
    cout << CurrentPath << endl;
    return 0;

Making this simple change will let the code compile in both CodeBlocks 8.02 and 10.05 without problem.

The main.cpp file for Listing 2-2 on page 591 is missing completely. The code in the book contains an extra curly brace at the end, so a number of readers have complained about this particular example. Here is the the source code for the main.cpp file that was supposed to appear in the \Author\BookV\Chapter02\PrecisionFunction folder of the CD.

#include <iostream>
using namespace std;
int main()
    int i;
    for (i=1; i<=10; i++) {
        cout << 1.0 / i << endl;
    cout << 2.0 << endl;
    cout << 12.0 << endl;
    cout << 12.5 << endl;
    cout << 123.5 << endl;
    cout << 1234.9 << endl;
    cout << 12348.8 << endl;
    cout << 123411.5 << endl;
    cout << 1234111.5 << endl;
    return 0;

All of the examples in Book V Chapter 3 will compile just fine and execute without error, but readers have complained that some examples don’t work as expected due to the UAC in Windows Vista and Windows 7. Paths such as /MyData/delims.txt (found in the \Author\BookV\Chapter03\ReadString01 and \Author\BookV\Chapter03\ReadString02 folders) worked fine in the past, but if you encounter problems, change them to something like C:/author/delims.txt to ensure you have rights to read and write the files. As odd as it might seem, you won’t even see a UAC message when the error occursWindows will simply refuse the write the file.

In Book V Chapter 4 you’ll encounter a warning message for the GetDirectoryContents example (found on page 613 and the \Author\BookV\Chapter04\GetDirectoryContents folder) that the & should be surrounded by parenthesis. The affected function is DumpEntry(). The parenthesis should appear around the (data.attrib & _A_SUBDIR) part of the if statement to avoid potential confusion as shown here:

void DumpEntry(_finddata_t &data)
    string createtime(ctime(&data.time_create));
    cout << Chop(createtime) << "\t";
    cout << data.size << "\t";
    if ((data.attrib & _A_SUBDIR) == _A_SUBDIR)
        cout << "[" << << "]" << endl;
        cout << << endl;

If you changed the /MyData/delims.txt path earlier to avoid UAC issues, you’ll likely also need to change the paths in the \Author\BookV\Chapter04\RenameFile example. This example also uses paths such as /mydata/dog.txt, which could cause problems with Windows Vista and Windows 7. Otherwise, the examples in Book V Chapter 4 should work precisely as they appear in the book with CodeBlocks 10.05.

Finally, the sole example in Book V Chapter 5 should work precisely as shown in the book with CodeBlocks 10.05. If you encounter any other problems with Book V, please be sure to let me know. In the next post I’ll start
with Book VI Chapter 1. In the meantime, keep those e-mails coming to