Skip to main content

Posts

Extend your list of debug tools with Sanitizers

How many ways to check if code is OK do you know? Probably the one would make a list with debuggers, logging, static/dynamic checkers, profilers and some other tools. The tools the one has in the list are there cause they've been checked with a time. They don't cover all the possible cases of mistakes that could be made during coding phase of a project, but they cover necessary minimum. Today we will try to extend our tool set with a young tools that already got into clang and if you have clang on your machine you can give it a try.



Recent posts

Templates and how to fold them

Variadic templates appeared in C++11 to cover such cases when you would have a template functions that could have a numerous members of different types. Doesn't it remind you of variadic functions that uses va_start, va_arg, va_end and so others? Cause it should be.


Tuples: are they useful?

In some languages there is such a thing as tuple which makes real to write such code (this time it's in python):


def f(x):
 # do stuff return (True, modified_string)

success, modified_string = f(something) 
C++ hadn't such feature until C++11. That was one of the reasons to pass variable as referenced argument, which ended up creating huge code bases that have unused arguments in it's functions. That happened in order to save revers compatibility and allow clients to use stable interfaces to access libraries without checking the version of dynamically attached library in order to use correct functions.

OpenGL: how to start studying?

I've been studying OpenGL for about 2 years, but I haven't got far with it and had no idea what is wrong. Is it me unable to understand OpenGL abstractions or is it designed not very well? I was looking for an answer all these years when suddenly I've started getting into math since my job required some math skills and suddenly OpenGL started to make sense for me. I ain't trying to say that now it's fun and games - honestly I find it challenging, but not as bad as before.

Move semantics

For a long time in C++ was no fast way to deal with return value. They were copied and there was no hope to change it. Some have used return parameters in argument list like:
void GetObjectsInArea(Area exactArea, ObjectList& objList);
To avoid unnecessary copies and speed up the execution developers were doing a lot of work. Eventually when optimized code were becoming unreadable the developers would abandon it and the code would transform into legacy code at some point.

Constness of an object

Defining a function you might want to make some of it's arguments to be constant to avoid unnecessary copying or have a bit more strict interface. There is another way to use constness - there we meet constant class members.