define extern function printf style in ispc for logging

118 views Asked by At

I want to implement a debugging function for my ispc code that can take a logging level as an argument and then printf style string and arguments.

The signature would be something like:

extern "C" void debug_log(enumDebugLevel debugLevel, char *literalString, ...);

I can see that ispc doesn't support "Variable numbers of arguments to functions" neither does it support strings or the char data type so I am thinking that the chances are pretty limited.

However, there is a built in function called print that works with both string literals and variable argument count. I am wondering if there is a way to implement my function as an extern function even though ispc itself does not support these features.

1

There are 1 answers

0
pbrubaker On BEST ANSWER

I'm assuming you don't have a console window in your application? If that's the case one thing you could do is redirect stdout/stderr to your logging system. There are a lot of SO discussions on that.

However, I had requested a change to allow print() to call through to OutputDebugStringA() on Windows but being able to provide a custom callback is a great suggestion. I will add this suggestion to the following GitHub issue.

https://github.com/ispc/ispc/issues/2140

I am part of the ISPC team at Intel and outside suggestions/questions are very welcome. It's best to reach us on GitHub though!