Code::Blocks on the Mac

A lot of Mac users have written to complain about the stability of Code::Blocks 8.02 on the Mac. This is the version used for the 2nd Edition of C++ All-in-One for Dummies. My first recommendation is that you obtain a copy of C++ All-In-One for Dummies, 3rd Edition if at all possible. This edition of the book contains additional installation details, updated examples, and all sorts of extras that will make your C++ learning experience so much better. Of course, not everyone will want to make the upgrade, but I stick by previous posts saying that some examples won’t work as well as they might if you use a different version of Code::Blocks than specified in the books. However, I also feel your pain. I personally didn’t experience stability problems with the 8.02 release and I’m sure others didn’t either, but enough people have complained that I feel obliged to discuss the issue in a post.

The Code::Blocks 13.12 version used for the 3rd Edition book is considerably more stable than the 8.02 version used for the 2nd edition book. If you really must continue using the 2nd edition book with your Mac, I suggest that you update to Code::Blocks 13.12 if you find that the 8.02 version causes you problems. If you go this route, please be sure to read the Using Code::Blocks 13.12 with C++ All-in-One for Dummies post. It provides you with information you absolutely must have in order to use the updated version successfully.

I always want to hear your book-specific input at John@JohnMuellerBooks.com. Your input helps me create better books and it also allows me to provide posts like this one that help readers work around potential issues. Thank you for your continued support of my books!

 

C++ All-in-One for Dummies 3rd Edition Extras

A number of you have pointed out that the extras for C++ All-In-One for Dummies, 3rd Edition on the Dummies site are a bit confused at the moment. Thank you, as always, for your input. I always appreciate getting your e-mails on any topic that affects the usability of my books. The publisher has assured me that the links will be cleaned up. Of course, eventually getting the links fixed won’t help you today. With this in mind, here is a list of the actual extras for this book—the elements that I’ll support and that provide support for the book:

To access a particular extra, just click its link in the list. Of the items you can download, the items that I most strongly suggest you download are the code examples. Downloading the code examples will save you considerable time, reduce potential errors, and make your experience with the book a lot better. If you want to type the examples in by hand, try them first using the downloaded code and then type them in. Using this two-step process makes it possible for you to easily see typos that you make as you work with the code on your own.

Remember that this edition of the book uses a newer IDE, Code::Blocks 13.12. Even though some examples will work with the older versions of Code::Blocks used in the second edition, other examples won’t. Upgrading your copy of Code::Blocks to version 13.12 ensures that you see the examples as they are meant to work. A few readers have asked about the requirements for using the extras and you really do need Code::Blocks 13.12 to use them correctly. You can also get by with a compiler that provides C++ 14 support, but you’ll need to modify the procedures to use that compiler, rather than Code::Blocks. I don’t provide support for other compilers because I don’t have them installed on my system.

Please let me know if you have any other questions about the extras for this book. It’s important to me that you get the maximum value from your purchase. Report any problems to me at John@JohnMuellerBooks.com. Of course, I always want to hear your book-related queries as well.

 

Fixed C++ Book Link

Last week I announced the release of C++ All-In-One for Dummies, 3rd Edition and told you about a link for the book extras at http://www.dummies.com/extras/cplusplusaio/. Unfortunately, the link didn’t work for a while. Clicking the link produced an error message, rather than a page full of useful content. The publisher has fixed the link and you can now gain access to a lot of really cool book extras:

All these extras will make your reading experience even better. Make sure you check them all out. Of course, I always want to hear your book concerns, especially when it’s something major like not being able to find needed content. Please feel free to contact me at John@JohnMuellerBooks.com with your book-specific question.

 

Announcing C++ All-In-One for Dummies 3rd Edition

I’m really excited to announce the release of C++ All-In-One for Dummies, 3rd Edition. This is the book that:

  • Provides all the updates you’ve been wanting
  • Relies on the latest version of Code::Blocks
  • Includes better support for Windows, Linux, and Mac installations
  • Contains all the latest techniques, including lambda expressions

This is the book update that I discussed in Beta Readers Needed for a C++ Book Update. Here’s the new book layout:

  • Book I: Introduction C++
    • Chapter 1: Configuring Your System (18 Pages)
    • Chapter 2: Creating a First C++ Program (20 Pages)
    • Chapter 3: Storing Data in C++ (30 Pages)
    • Chapter 4: Directing Your C++ Program Flow (26 Pages)
    • Chapter 5: Dividing Your Work with Functions (26 Pages)
    • Chapter 6: Dividing Between Source-Code Files (16 Pages)
    • Chapter 7: Referring to Your Data through Pointers (30 Pages)
    • Chapter 8: Working with Classes (38 Pages)
    • Chapter 9: Using Advanced C++ Features (36 Pages)
  • Book II: Understanding Objects and Classes
    • Chapter 1: Planning and Building Objects (30 Pages)
    • Chapter 2: Describing Your Program with UML (20 Pages)
    • Chapter 3: Structuring Your Classes with UML (12 Pages)
    • Chapter 4: Demonstrating Behavior with UML (18 Pages)
    • Chapter 5: Modeling Your Programs with UML (12 Pages)
    • Chapter 6: Building with Design Patterns (30 Pages)
  • Book III: Fixing Problems
    • Chapter 1: Dealing with Bugs (12 Pages)
    • Chapter 2: Debugging a Program (14 Pages)
    • Chapter 3: Stopping and Inspecting Your Code (12 Pages)
    • Chapter 4: Traveling About the Stack (10 Pages)
  • Book IV: Advanced Programming
    • Chapter 1: Working with rays, Pointers, and References (30 Pages)
    • Chapter 2: Creating Data Structures (22 Pages)
    • Chapter 3: Constructors, Destructors, and Exceptions (28 Pages)
    • Chapter 4: Advanced Class Usage (26 Pages)
    • Chapter 5: Creating Classes and Templates (32 Pages)
    • Chapter 6: Programming with the Standd Libry (38 Pages)
    • Chapter 7: Working with Lambda Expressions (16 Pages)
  • Book V: Reading and Writing Files
    • Chapter 1: Filing Information with the Streams Libry (14 Pages)
    • Chapter 2: Writing with Output Streams (16 Pages)
    • Chapter 3: Reading with Input Streams (12 Pages)
    • Chapter 4: Building Directories and Contents (10 Pages)
    • Chapter 5: Streaming Your Own Classes (12 Pages)
  • Book VI: Advanced C++
    • Chapter 1: Exploring the Standd Libry Further (20 Pages)
    • Chapter 2: Working with User Defined Literals (UDLs) (16 Pages)
    • Chapter 3: Building Original Templates (20 Pages)
    • Chapter 4: Investigating Boost (26 Pages)
    • Chapter 5: Boosting Up a Step (16 Pages)
  • Appendix A: Automating Your Programs with Makefiles (12 Pages)

As you can see, this new book focuses a lot more strongly on standardized C++ so that you can get more out of it. There isn’t any mention of Microsoft special features any longer. You can use this book in all sorts of environments now and expect the examples to work (with some modification depending on how well your compiler adheres to the standard). Most importantly, there is now a chapter specifically designed to help you get your system configured so you can begin enjoying the book in a shorter time.

As always, I highly recommend you download the book’s source code from http://www.dummies.com/extras/cplusplusaio/ (the source code appears at the bottom of the page, so you must scroll down). In addition to the source code, the site also contains a wealth of extras that you really want to check out as part of your book purchase. Of course, there is always room for additional information, so let me know about the topics you’d like to see covered on the blog as well. You can check out the current posts at: http://blog.johnmuellerbooks.com/category/technical/c-all-in-one-for-dummies/.

I’m really excited about this new book and want to hear from you about it. Please feel free to contact me about any questions you have at John@JohnMuellerBooks.com.

 

Using Code::Blocks 13.12 with C++ All-in-One for Dummies

As stated in my Beta Readers Needed for a C Book Update post, I’m currently working on an updated version of C++ All-In-One Desk Reference For Dummies. The 2nd Edition book that is currently available relies on Code::Blocks 8.02 (the version I still recommend you use with this particular edition), which is really long in the tooth at this point. I’ve provided a number of update posts since the book was released to help you use Code::Blocks versions 10.05 and 12.11. However, as the example code has gotten older, more and more problems have surfaced with the example code because C++ itself has changed. The new book will use Code::Blocks 13.12, so the example code problems will disappear.

Most of the book examples for the 2nd edition will still compile with Code::Blocks 13.12, but not all of them will (the series of Code::Blocks 10.05 update messages should give you some idea of the problems you’ll encounter using a newer version). However, there are issues with one of the Code::Blocks 13.12 releases that will cause you serious problems in using the book. If you insist on using the latest version of Code::Blocks, make sure you download the codeblocks-13.12mingw-setup.exe file and not the codeblocks-13.12mingw-setup-TDM-GCC-481.exe file. According to the site, this second file has some issues with Code::Blocks. A note on the site page at http://www.codeblocks.org/downloads/26 explains the problem. Essentially, the GCC 4.8.1 release has problems with Code::Blocks, so you’ll see behavior that has nothing to do with the example code if you use it.

One of the beta readers for the new edition actually pointed out this problem. He inadvertently installed the buggy version of GCC 4.8.1 and I was able to see first hand that it really does cause some serious issues. (Actually, we couldn’t figure out what was going on at first.) This is one of many reasons I love to use beta readers when working on my books. In finding just this one problem (and he has found others), this beta reader prevented a whole lot of other readers from having issues with my new book .

I always want to hear about issues you have with my books. If you find that you have problems with the examples after reading through the posts on my blog, please contact me at John@JohnMuellerBooks.com and tell me about them. In many cases, the only way that I know a problem exists is when you make me aware of it. Thanks again for all your helpful support over the years!

 

Entering Data in a Code::Blocks Window

Sometimes it isn’t very obvious how to enter data into a Code::Blocks window. One of the windows that seems to be causing problems for a number of readers is the Watches window. You open this window by choosing Debug | Debugging Windows | Watches. The purpose of this window is to let you view the content of variables in your application, which is an essential part of the debugging process. In order to view the variable (or other expression) content, you must enter it in the Watches window. Book III of C++ All-In-One Desk Reference For Dummies tells you all about debugging.

One technique for entering the variable is to select it in the editing window and the drag it to the Watches window. The variable will appear in the Watches window along with its value. However, this approach only works for variables and expressions that actually appear in your code. You might want to enter some other expression (or manually enter the variable, rather than drag and drop it). The Watches window consists of rows and columns as shown here.

WatchEntry01

The name of the variable or the expression you want to view appears in the first column. To enter a new value into the Watches window, click directly in the first empty left column cell. The row will turn blue and you’ll see a red insertion point appear in the cell as shown in the screenshot. Now you can type the variable name or expression you want to work with and press Enter. Let’s say your variable is named i. It might look like this:

WatchEntry02

Notice that the row is now white because it isn’t selected. However, you can see the name of the variable, i, it’s value 1983844706, and it’s type int. The row is in red because the value of i has just changed (unchanged values appear in black so you can see them easier). As you debug your application, you can now watch the value of i for changes.

Sometimes it isn’t obvious how to enter information into Code::Blocks (or any other application for that matter). When that happens, the focus turns to the application, rather than the work you need to do, and the experience becomes frustrating. Let me know about your book-related Code::Blocks questions at John@JohnMuellerBooks.com and I’ll do my best to answer them. Because I don’t have a direct connection to the vendor, my ability to answer other sorts of questions is limited.

 

Finding Code::Blocks Tutorials

Sometimes it’s hard to know precisely how to cover information in a book because each reader’s needs are different. One reader may be somewhat knowledgeable and not need tutorials, another reader might me a complete novice and require more assistance. Over the years, I’ve come to appreciate the landslide of comments I receive about my language books when they deviate to discuss topics other than the language. Most readers don’t want to read about anything other than the language. In fact, in a few of my language books I’ve stopped mentioning any sort of IDE except in passing (and sometimes not at all).

C++ All-In-One Desk Reference For Dummies is a little different from most of my language books in that it must make mention of an IDE in order for the reader to follow all of the examples. Because I want the book to work well on all platforms, I’ve chosen Code::Blocks as the IDE for this book. This particular IDE works on all of the platforms that the book supports (Mac, Linux, and Windows) in a similar fashion, so one set of instructions works for everyone. In addition, Code::Blocks enjoys great community support and has a large enough user base that it’ll be around for a long time.

This book does contain a few bits of information about Code::Blocks because it must in order for the reader to follow the examples. However, I’ve purposely kept the amount of information about Code::Blocks to a minimum because this really is a language book and you could use any IDE with it, not just Code::Blocks. It’s difficult to walk the line between providing enough information about the IDE and not enough. Whether I’m successful depends on the skill level of the reader for the most part. The beta readers of the current edition are definitely letting me know where I need to add more information to ensure the material is understandable, but there will always be some room for readers to feel there is either too much or too little coverage.

With this in mind, I’ve provided posts such as Pausing the C Example Output in the C++ All-in-One for Dummies category. If you have a question about how to perform a task in the book, this is the first place to look. Make sure you contact me at John@JohnMuellerBooks.com if you have questions, because then I’ll know to discuss the topic as part of a blog post. What it all comes down to is my wanting to provide you with the information you need, but not knowing what that requirement is until you contact me. As more readers contact me and the list of posts grows (59 including this one) the chances of finding what you need in one place becomes greater.

Code::Blocks also comes with a nice help file, but you might not know it. Choose the Help | Codeblocks option and you’ll see a new window pop up with the help information. I must admit that it would have been better had the vendor provided a different command for accessing the help file, but at least the help file is there.

Even with these two resources, you’ll likely find situations where you need more information. As I said, Code::Blocks enjoys good support in the development community. The following list contains some tutorials you can try when none of the other sources I’ve mentioned help.

There are other tutorials available. What I need to know is whether these tutorials answer your questions or not. If not, what topics do you need covered that my blog doesn’t already discuss? It’s important to me that you have a good learning experience with my books so always feel free to contact me about topics you’d like to see covered in the blog.

Pausing the C++ Example Output

A number of readers have written to ask about running the example code in C++ All-In-One Desk Reference For Dummies. The book shows that the examples pause so you can see the output, yet a few people experience problems getting the example to pause as shown in the book. Let’s take the first book example. When you run the example, you should see a command window similar to the one shown here open.

ExamplePause01

This is how the command window looks in Windows, but if you use some other operating system, you should see something similar. Notice that the output is paused. Pressing any key will cause the window to disappear and the example to end. The purpose of pausing the output is so that you can see the result.

There are two common reasons that people aren’t seeing the output pause. The most common reason is that the example is run in debug mode. Make sure you click Run or choose Build | Run to execute the example. If you click Debug/Continue or choose Debug | Start/Continue instead, the example will execute without pausing and you won’t see the output. Of course, you can always set a breakpoint to get the example to pause, but most people simply want to see the example output which means running the example, rather than debugging the example.

A less common cause is that the project environment is configured incorrectly. Normally the Code::Blocks environment automatically pauses when you run the example. However, it’s possible to set Code::Blocks not to pause. Some readers inadvertently change this setting while exploring the environment. In order to check this setting, choose Project | Properties to display the Project Targets/Options dialog box. Select the Build Targets tab and you see the dialog box shown here.

ExamplePause02

Notice the Pause When Execution Ends option. If this option is cleared, the example won’t pause when you run it. Make sure this option is checked and click OK. The projects that come with the downloadable code all have this setting set up correctly.

Of course, there could always be other reasons why the examples aren’t pausing. Please let me know if you have any problems setting the example output. It’s essential that you be able to see the example output as you follow along in the book to understand how C++ works. Send your queries about this (or any other book-specific) topic to John@JohnMuellerBooks.com. I always want to ensure you have the best possible experience when using my books.

 

Beta Readers Needed for a C++ Book Update

A lot of people (892 so far) have sent me e-mail about C++ All-In-One Desk Reference For Dummies. A few more have commented online and some of you have written reviews as well. In fact, it’s one of the more popular books I’ve written to date. I keep statistics on every message I receive so that I can better understand how a book is succeeding and how it has failed. For example, I know that most readers like CodeBlocks, but they wish my book used a newer version of the product. Don’t worry, the updated book will use the latest CodeBlocks release. I’ve also discovered that none of you apparently uses the Microsoft-specific materials in Book VII—this information will be replaced with something you do want in this next edition. All of the examples will also be tested on the Mac, Windows, and Linux platforms to ensure it works well no matter what platform you use.

Naturally, everything that requires an update in the book will get updated. I’ll also look at the latest specification and determine what sorts of new topics might interest you. However, I really do need your input. Only you actually know what you’d like to see in an updated book and I’m determined to find out what that is. You can help me shape the updated book by writing me at John@JohnMuellerBooks.com with your ideas and suggestions. Don’t wait until later, write me today!

Even better, why don’t you become a beta reader? You’re under no obligation to read the entire book. I’ll send you the chapters as I write them and it’s entirely up to you to send them back with comments. I’ll never bug you for comments. Any comments you do send will receive careful consideration and I’ll modify everything I can as I go through the Author Review (AR) process where I incorporate editor comments as well. By being a beta reader, you get to shape the book content and get precisely the book you’d like. Make sure you sign up to be a beta reader today.

As part of being a beta reader, your name will appear in the book Acknowledgements (unless you specially ask that I don’t provide it). However, one of the bigger benefits to you is that you get to read the book free of charge and gain the skills that it can provide for you. Imagine what learning a new programming language can do for your career. Even if you don’t need C++ for work, you can use what you gain to create applications for your own needs and to obtain a better understanding of how computers work.

Many people are concerned that they don’t qualify to be a beta reader, but that’s not the case at all. You don’t need to know anything about C++ or programming for that matter to be a beta reader for this book. All you need is a desire to learn how to use C++ to develop simple applications. It really is that simple.

 

Resetting Your CodeBlocks Configuration

Quite a few people have written to me about issues they have with C++ All-In-One Desk Reference For Dummies that involve getting CodeBlocks up and running. The posts in the C++ All-in-One for Dummies archive normally provide everything needed to get the compiler up and running. I even provide posts on using the 10.05 version of the product, should you wish to upgrade. However, there are rare times when no matter how much you try, you simply can’t get the compiler to work.

One technique I haven’t really covered until now is to reset the CodeBlocks configuration. The problem with this approach is that it resets all of your settings, not just those that could be in error. This is the reason that I’ve taken a more measured approach to helping readers through problems until now. My concern is that resetting everything will actually cause more problems and end up confusing some readers, so you really do want to try those other posts first. That said, there are situations where resetting CodeBlocks is the only course of action that will work.

To reset your settings, open your copy of CodeBlocks. Choose Settings | Compiler and Debugger. You see the Compiler and Debugger Settings dialog box shown here.

ResettingYourCodeBlocksConfiguration01

Click Reset Defaults. This action will reset all of the defaults so that they match the initial installation configuration unless you have created a default of your own. Make absolutely certain that the Selected Compiler field shows GNU GCC Compiler as shown in the figure and then click OK. Close and then reopen CodeBlocks before you test your configuration.

Let me know if you have any questions about this procedure at John@JohnMuellerBooks.com. It’s always my goal to make my books as useful to you as possible.