Einträge über C++

My GNU Autohell Story

In academic software development I have seen one software suite which was known to be hard to compile. I was tasked to do try it, and ended up writing a 1200 line Bash script which took care of all the edge cases.

Weiterlesen…

Python has no Variables

Python doesn't have variables. It sounds mind-boggling, as one seems to use them all along. But really, that is not how it works with Python. This will really confuse people with a background in C or C++. If we do int n in C++, and write n = 1, n += 1 or the like, the address &n will never change. The value changes.

Weiterlesen…

Finding a Stack Buffer Overflow

One of the danger of C-style arrays is that their length is not attached to the pointer that points to their beginning. This means that there are lots of unsafe library functions that might write beyond the allocated space.

Weiterlesen…

The Case for Standard Configuration File Formats

The numerical software that I work with is written as command line tools. As such, they get their parameters from command line arguments and/or parameter files. Their output is written to files as well. Since one can redirect standard output into a text file, we will only consider files here.

Weiterlesen…

C++ Cache Decorator

Pure functions only depend on their arguments and do not have any side effects (global variables, file I/O, ...). Their return value is completely determined by their arguments. If a function is expensive to compute and the argument space is small, it makes sense to cache the results to only compute them once in a program.

Weiterlesen…

Passing a C++ Lambda to a GSL Function

The GNU Scientific Library is a C library that offers (among other things) an integration routine. One does not pass a simple double (*f)(double) function parameter because there might be additional parameters needed. The article Currying in C lists various possibilities, the GSL implements the variant with the void *. A dummy implementation of this integration routine could look like this, for the purpose of this article:

Weiterlesen…