> C has a type system, but the developers are ignoring it, preferring to move stuff around as void *. Obviously, it shouldn’t be necessary to do that, and this was one of the things I wanted to fix by moving the code into a C++ compiler.
> This is a case of one function infecting the entire code base. In this case, a function that is often invoked, the xmalloc family, a wrapper over malloc-like functions that return pointers to void.
This makes no sense to me. In C, you can assign a void pointer to any typed pointer, no casting required, i.e.:
struct foo *f = malloc(sizeof(*f));
The answer here isn't to rewrite it all in C++, but to learn C in the first place.They may be referring to xmalloc(3).
What you said is true however they are transitioning to a C++ compiler so your complaint is off-base.
> however they are transitioning to a C++ compiler
OP says they want to transition to a C++ compiler but it's not clear why, the very first issue is not actually one. As GP notes, you don't need to cast out of malloc and you need a macro even less.
When the article says that implicit conversations from void* "shouldn’t be necessary" they seem to mean they feel that, philosophically, it ought not to be necessary. Certainly it doesn't protect against obvious compile time mistakes, which ought to be the point of a type system:
/* Compiles in C */
int* x = malloc((sizeof)short)
// Does not compile in C++
int* x = new short
I mean sure, but that seems like a minor thing compared to the codebase passing around void*'s left and right. OP could have tackled that first while sticking with C.
I've had a brief look over the goaccess source code. It's 37kloc of pretty average looking C. If you think that's even close to the most complicated software projects written in C then I don't know what to tell you.
EDIT: looked at the code... I don't see void* being passed around, data types are used, no excessive #ifdefs, it looks like a pretty clean C app to be honest. Maybe the problem is that OP is used to C++? (as the advice to use a special struct for strings would indicate)
Either way, goaccess project looks awesome.