"hello world"
article in Tech programming

C / C++ - libraries, tips, tricks and gotchas

I love programming in C and C++. It is a language which allows for fast close access to the machine's hardware. It was also the first programming language I became proficient in. It is portable in that you can find a C/C++ compiler for most every hardware platform available. Native C/C++ dlls are easily accessed from other languages like .net,java,python,etc.

Programming in C/C++ does require one to give more thought to memory management. You can shoot yourself in the foot if you are not careful. Using safe functions is a must (strncpy,snprintf,etc), buffer overflows abound. Memory leaks can and do happen. But, tools help and defining destructors is not rocket science....but remembering the details is important. :)

Because C/C++ is portable, it doesn't spec out a huge base class library...not to the extent of Java and .NET anyways. You'll usually need to create/use a framework/library for implementing the higher level stuff (gui,graphics,sound,etc). There are many good C/C++ libraries/frameworks available on the net, some of them are linked on this page.

Having said all this. I believe C/C++ will carry on with us for a long time to come.
Woot! Long live C/C++;

Standard C++ Blog : Standard C++
GoingNative 2013 | Channel 9
C++ Rocks
C11: A New C Standard Aiming at Safer Programming
Articles about programming - a few on C++, povusers.org
cdecl: C gibberish ? English - cool C gibberish to English
Improving and Fixing C Code
mikeash.com: Friday Q&A 2013-05-31: C Quiz - mike's site has a lot of great stuff on Objective-C too.
Dr. Dobb's | An Interview with Bjarne Stroustrup | March 27, 2008
Eli Bendersky’s website » Blog Archive » The many faces of operator new in C++
Obscure C++ Features - Made by Evan
Cello • High Level Programming C
Notepad++ Home - Based on the powerful editing component Scintilla and SciTE, Notepad++ is written in C++ and uses pure Win32 API and STL. It's free, and open source.

C++ Boost

Why is it that you haven't heard of boost? and why aren't u using it?
Boost C++ Libraries
Boost C++ Libraries Installers for Windows - BoostPro Computing
Tech Notes of Yi Wang: Incremental Parsing Using Boost Program Options Library - Yi Wang's whole site is full of great content...
Boost Windows Pre-Built Binaries - thanks to teeks99! quite exhaustive set of boost builds. (also know that building them yourself is as simple as bootstrap.bat;b2; (for x64- bjam address-model=64 --build-type=complete stage))
alexott/boost-asio-examples · GitHub What is Boost.Asio, and why we should use it
Thinking Asynchronously in C++
threadpool Documentation
Test-driven development and unit testing with examples in C++ alexott/cpp-tesing-examples · GitHub
Add HTTP Services into C++ Programs Using PION-NET « Yi Wang's Tech Notes
cloudmeter/pion · GitHub - Pion Network Library (Boost licensed open source)
tonicebrian/RESTcpp · GitHub - DSL for defining REST interfaces in C++ (pion dep)
acmorrow/dslam · GitHub - An toy express/sinatra style framework for writing webservices in C++11. (pion dep)

threadpool Documentation
Toni Cebrián » Thread pool in C++ - using boost::thread_group,asio::io_service.

Unicode C++

ICU - International Components for Unicode - ICU is a mature, widely used set of C/C++ and Java libraries providing Unicode and Globalization support for software applications.
cloudmeter/icu4c · GitHub

Data access for C and C++

RTA - LGPL library which can expose your program's internal arrays and data structures as if they were tables in a database.


MongoDB - MongoDB (from "humongous") is a scalable, high-performance, open source, schema-free, document-oriented database. Written in C++.
GridFS — MongoDB Manual - GridFS is useful not only for storing files that exceed 16MB but also for storing any files for which you want access without having to load the entire file into memory.
The Little MongoDB Book
Learn MongoDB - mongodb interactive tutorial, little mongodb book, mongodb's geospatial interactive tutorial.
The Dynamic Programmer - Using MongoDB from C#
samus's mongodb-csharp at master - GitHub - C# driver for MongoDB.
Automating partitioning, sharding and failover with MongoDB - Server Density Blog
MongoHQ - MongoDB Database as a Service
MongoLab: MongoDB-as-a-Service
Repair MongoDB on a Bad Restart | I Am Aaron Shafovaloff
Stream Tweets in MongoDB with Node.JS | Maikel Alderhout's Blog
Implement MongoDB replication in 3 simple steps | Maikel Alderhout's Blog
Fast datetimes in MongoDB - in scalar context - perl MongoDB DateTime::Tiny
Building a MongoDB App with Perl from Mike Friedman

Wt, C++ Web Toolkit - Introduction

C/C++ development with the Eclipse Platform

Unit Testing in C++

Unit testing is something that I really would like to see more of in C++ code. I love the idea of self documenting / self testing code. However, C++ lacks any sort of unit testing standards...so we are left to define one ourselves again. :(

Exploring the C++ Unit Testing Framework Jungle
CppUnit looks like a pretty good candidate:
CppUnit Wiki
CppUnit Cookbook

copy(container.begin(), container.end(), ostream_iterator(cout, " "));

Formatting I/O using IOSTREAMS

I'm always forgetting the diff. stream modifiers, here are a few that I use from time to time.
#include  //cout,cint,etc
#include  // setwidth,setfill,setprecision,etc
#include  // ostringstream

using namespace std;

int main()
    unsigned int number=47;
    cout << "Setting field width is simple.\n";
    cout << "For each variable, simply precede it with setw(n)"<
A really good article on iostreams is "Extending the iostream library", by Horstmann.  It explains how to do everything above, plus it includes a  manipulator to convert printf formatting commands to their stream  equivalents.  Very cool.

Static Class Constants

I'm always forgetting the syntax for properly defining static class constants.  The biggest problem is not defining it, but initializing static const data members.  The C++ Standard allows initialization of const static data members of an integral type inside their class.  But I don't suggest it, initialize all your data in one place.  Declare them inside your class header and implement them in your cpp file.
class Car
    static const int NUMDOORS; //definition
    static const std::string MSG; //non-integral type; must be defined outside the class body

// then inside the cpp file.
const int Car::NUMDOORS=4;
const std::string Car::MSG= "hello";

STL Information

STL Resources on MSDN - Visual C++ Team Blog - Site Home - MSDN Blogs

STL maps

I love STL maps because they allow you to specify an ordering of your keys and the map takes care of it automagically.

A multimap is an associative container that manages a set of ordered key/value pairs. More than one value can be associated with a particular key. The pairs are ordered by key, based on a user-supplied comparator function.
// Include this for map defines.

// Define a map.
std::multimap /* order as descending */> cityList;
// You can also order in ascending by using the less<> comparator.

// Inserting is a little strange because you've got to use a pair.
cityList.insert(pair(distance, city));

// Return location of first element that is not less than 100
  i = cityList.lower_bound(100);
  cout << "lower bound:\n";
  cout << ( *i ).first << " -> " << ( *i ).second << "\n";

// Return location of first element that is greater than 100
  i = cityList.upper_bound( 100 );
  cout << "upper bound:\n";
  cout << ( *i ).first << " -> " << ( *i ).second << "\n";

CodeProject: Casting Basics - Use C++ casts in your VC++.NET programs.
Casting in C++: Bringing Safety and Smartness to Your Programs

Standard include paths

This doesn't relate directly to C++, but it does come up when programming in C++... GCC has a bunch of standard search paths that it moves through to find your libraries and include files. If you want to include a new path to the standard set of paths, just define the env. var for it.
Environment Variables Affecting GCC

Code modeling

GCC-XML looks amazing when used with pygccxml

CLARAty Robotic Software - JPL's open robotic framework.
libMesh - C++ finite element library
DOLFIN - C++ ordinary/partial differential equations library.

Static analysis

Unfortunately, static analysis tools are not cheap. Here are a few that I know about. I wish there were some good open source alternatives.
Source Code Security Analyzers - SAMATE.nist.gov - list of static analyzers from NIST
Coverity Incorporated: Products: Coverity Prevent SQS for C/C++: Map the Software DNA
Insure++®: C/C++ Testing Tool, Detect elusive Runtime Memory Errors - Parasoft

Look Coverity for open source projects:Coverity Scan - Static Analysis
RATS - Rough Auditing Tool for Security - is a tool for scanning C, C++, Perl, PHP and Python source code and flagging common security related programming errors such as buffer overflows and TOCTOU (Time Of Check, Time Of Use) race conditions. CERN Computer Security Information RATS rough-auditing-tool-for-security - Rough Auditing Tool for Security (RATS) - Google Project Hosting
Splint Home Page - Splint is a tool for statically checking C programs for security vulnerabilities and coding mistakes.
PMD - PMD is a source code analyzer that also looks for copy and paste code (duplicate code)
Frama-C - source-code analysis of C , value analysis, effects analysis, dependency analysis, impact analysis.
Cppcheck - A tool for static C/C++ code analysis - Out of bounds checking,Check the code for each class,Checking exception safety,Memory leaks checking,Warn if obsolete functions are used,Check for invalid usage of STL,Check for uninitialized variables and unused functions.
Two Years (and Thousands of Bugs) of Static Analysis | Random ASCII

Managed C++/CLI

Junfeng Zhang's Windows Programming Notes : Conversion between System.String and char *
Junfeng Zhang's Windows Programming Notes : Reverse P/Invoke Marshaling Performance


main is usually a function: Embedding GDB breakpoints in C source code

LLVM Clang

The LLVM Compiler Infrastructure Project - LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
"clang" C Language Family Frontend for LLVM - Clang is an "LLVM native" C/C++/Objective-C compiler, which aims to deliver amazingly fast compiles (e.g. about 3x faster than GCC when compiling Objective-C code in a debug configuration), extremely useful error and warning messages and to provide a platform for building great source level tools.
[Phoronix] LLVM Post-3.4 To Most Likely Depend Upon C++11
Main — Emscripten documentation Emscripten is an LLVM-based project that compiles C and C++ into highly-optimizable JavaScript in asm.js format. This lets you run C and C++ on the web at near-native speed, without plugins.


BuildingWinDLL - KitwarePublic
CMakeModularizationStatus – Boost C++ Libraries
Ryppl ryppl (The Ryppl Project) - an attempt to create a PyPy or CPAN for C/C++. Boost,CMake,Git,ZeroInstall

Embedding a File in an Executable, aka Hello World, Version 5967 | Linux Journal - using objcopy to create linkable data objects.
c++ - Is Meyers implementation of Singleton pattern thread safe? - Stack Overflow - depends on your compiler. C++ and the Perils of Double-Checked Locking (PDF)

kripken/emscripten - Emscripten: An LLVM-to-JavaScript Compiler
Created: 2005-12-27 01:56:50 Modified: 2016-03-08 04:18:34
/root sections/
>peach custard pie
>random tech

moon and stars

My brain

Visible Dave Project

0, 1, 1, 2, 3, 5, 8, 13, 21, 34,...
xn = xn-1 + xn-2