Magic C++ Makefile

Makefiles are often touched on, but rarely described in depth. It is easy to start a makefile, but it becomes quite difficult to keep it up to date. Dependencies get missed, source files get missed, and the entire thing is a pain to read. Much better, overall, to have make determine everything automatically. Read more

Tags: C++ , Make

My Preferred C++ Style

A friend recently asked me for advice in how to structure C++ code. It made me need to think through what rules I tend to follow. Read more

Tags: C++

Lua bindings, C++ Functions, Loose Ends

There are a few loose ends that are left over from the exposing of C++ functions to be used in Lua. Read more

Tags: C++ , Lua

Lua bindings, Calling C++ Functions

As of last time, we can set global variables, read global variables, and call Lua functions. However, once inside Lua, we cannot make calls that return to C++. These could be useful in many situations. For example, numerical code can be written in C++ for greater speed, then called from Lua. Alternatively, the Lua code may be a callback in a GUI framework, which needs to call C++ functions to change the state of the GUI. Read more

Tags: C++ , Lua

Lua bindings, Calling Lua Functions

From last time, the messiest part of the code was the calling of the Lua function. It gets even messier when there are arguments being passed or returned. Suppose we want to call the following Lua function. Read more

Tags: C++ , Lua

Lua bindings, Global Variables

Yeah, yeah, I know. Global variables are bad, treacherous, make the program hard to reason about, lead to spaghetti code, and smell funny. However, they are a good first step for passing information back and forth between Lua and C++. Read more

Tags: C++ , Lua

Lua bindings, Introduction

Embedded languages allow for easy extension of existing programs. I like C++, but everything must be done at compile time. Extension code, written in an embedded language and called from the C++ program, can be added or modified without needing to re-compile the main executable. The embedded language may provide more flexibility, which makes development easier. The extension code may be written by the user, to provide features that they want in the code. And it has been something that I have been meaning to try out for a while, and there’s no better time than now. Read more

Tags: C++ , Lua

C++, decltype and getter/setter

decltype is a new feature available in C++11. It is generally used in templates, where the return type of a function may need to be determined from the input types. When I heard of it, I thought that it might make getters and setters be easier to define. After all, it would be nice to only need to state the type of a variable once. Read more

Tags: C++

Cross-platform C++

I like developing in linux. The ecosystem is nice, tools cooperate together nicely, and the command line is a joy. However, my main computer and my friends’ computers tend to be Windows computers. If I write programs, I want them to run anywhere. Read more

Tags: C++

Runge-Kutta in C++

In my previous post, I went through the benefits of using Runge-Kutta for numerical solving of differential equations. Now, a sample implementation. Read more

Tags: Mathematics , C++