Open Scraft opened 9 years ago
This is a very good idea.
I would love to add this right now but the public interface is very inflexible in terms of adding new permutations. I want:
So instead of adding a new named macro for different sample types it's added as a parameter, like:
rmt_BeginSample(CPU, Name)
Adding auto name would explode existing combinations even more. I should really solve this. In fact, once this is solved the only way I can think of adding the auto name feature is the same way you've done it. Unless you require names to be strings, which I'm not sure I want.
In terms of implementation, it's probably best to generate a unique symbol for the sample variable using the __COUNTER__
macro:
#define JOIN2(x, y) x ## y
#define JOIN(x, y) JOIN2(x, y)
#define UNIQUE(x) JOIN(x, __COUNTER__)
I wanted to be able to just drop in a single macro in a bunch of functions, and have the API auto fill-in the function names for me, i.e.
I didn't want to have to manually pass in a name to each call. My solution:
This generates a call tree like:
Sorry this isn't a proper full request, but I hoped this might be something you'd consider implementing (either as is, or in a better way if you know of one).