define extern function printf style in ispc for logging - ispc

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.

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!

Related

How to change Doxygen macro / function arguments formatting?

I want to change Doxygen macros and function arguments formatting. Whatever this formatting is trying to achieve can be done with #param, which will describe function parameters way better in the section down below. Also, explicitly saying void as function arguments formats it with some strange spacing, while right above it Doxygen understood that nop(void) is equal to nop(), which just drives me crazy.
I think that macro / function arguments formatting should be a configurable option. I want to change mine formatting from multiline to one line, since I don't see the benefits of doing otherwise.
#define ADD(a, b) a + b
int add(int a, int b)
I couldn't find anything about function arguments formatting. About void people said to use aliases, but gave no examples, so I am stuck here. Hope I gave enough info on what I am trying to achieve!

Elusive MATLAB built-in function

I am trying to read the following internal MATLAB function:
>>which visionInitializeAndExpandCheckerboard
built-in (C:\Program Files\MATLAB\R2015a\toolbox\vision\vision\visionInitializeAndExpandCheckerboard)
But it appears to be hidden away! And very well hidden.
None of the following methods to access it have worked:
Highlighting the name and pressing Ctrl+D.
Typing "edit visionInitializeAndExpandCheckerboard" in the command line.
Searching for the file in Matlab's own FindFiles.
Searching for the file on the disk.
Trying to Step Into the function in debug mode (I just get the output as if I had requested Step Out instead).
Btw, the reason I am looking into this is that the parent function detectCheckerboardPoints has seriously declined in performance from R2015a to R2016b and I am trying to figure out why.
The internal function is compiled native code, so you will not be able to see its source. If you see a performance degradation, you should call Mathworks tech support and complain. If it is something they can fix, they will send you a patch, and fix it in the next release.

In a function show passed arguments in a different color [duplicate]

In Emacs, is it possible to mark all variables of different data types with different colors? e.g. if I have the following variables in C/C++ my program
int i,j;
float g,h;
char a,b;
Then throughout the source code i and j would be marked as red, g and h as green, a and b as blue.
I am not sure how useful this will be in future, but I feel it would help me while reading code,
and be a good alternative to the Hungarian notation(not that I use this notation :D).
No. Emacs has no idea about the type of a specific expression; doing this would be tantamount to writing a significant part of a C compiler in ELisp.
However, there is a light at the end of the tunnel.
E.g., if you edit OCaml code using tuareg-mode, you can ask Emacs about the type of any expression because the ocaml compiler provides that information; thus you should be able to ask it to highlight variables by type. This is the path to follow.
Alas, gcc does not provide that information; however, its extensiongccxml does.
Also, other C compilers, e.g., clang, provide that information out of the box, and there is a new file semantic-clang.el which relies on those features (although for completion only, not for syntax highlighting).
So, nothing out of the box for you here, but if you are willing to use clang instead of gcc and contribute to the CEDET development, you might get what you want.
No, it's not possible to selectively assign a given color to a given variable in emacs (or just for one given program).
However, if it's just syntax highlighting you are looking for, of course, emacs will highlight most languages, and you can even create syntax highlighting for languages emacs would not know about.
Ex. Smali: https://github.com/strazzere/Emacs-Smali

How to access inbuilt functions?

As what should I be typing in the Command Window to get the function file to open?
Usually I get a link to them when debugging and an error occurs, but what command can be used to access them directly?
edit functionName, e.g. edit repmat.
There are built-in functions that are not written in Matlab, but for these functions you cannot take a look at the code even if an error occurs.

/SUBSYSTEM:Windows program will not write to command line

I have a mixed mode C++-CLI program in Visual Studio 2005 that is set to use the /SUBSYSTEM:Windows. Generally speaking it is a graphical application that is launched from its shortcut or through the filetype registered to it.
However, there is a rare occasion where a user will want to run it from the command line with arguments. I can access the arguments just fine, its when it comes to writing to the console, in response to the program being launched from the command line with arguments, where I don't see Console::WriteLine having any effect.
What am I doing wrong?
This one's annoying, I agree. You're not doing anything wrong, it's a quirk of the way Windows is set up.
It is possible to solve this, at least in some cases, see http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx . I've not come across anybody else who's actually used these methods though.
Most people IME just create two versions of the executable with different names, one for batch users ("myapp.exe") and one for when it's run from the start menu ("myappw.exe").
For more information, some of the suggestions at How to output to the console in C++/Windows may be useful.
It's an old problem - see http://www.codeproject.com/KB/cpp/EditBin.aspx for solutions
You can also reopen the streams to a console
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE /*hPrevInst*/, LPSTR cmd_line, int showmode)
{
AllocConsole(); //create a console
ifstream conin("con"); // not sure if this should be "con:" ?
ofstream conout("con");
cout.rdbuf(conout.rdbuf());
cerr.rdbuf(conout.rdbuf());
cin.rdbuf(conin.rdbuf());
FreeConsole();
return 0;
}
edit: sorry this is pure C++, don't know about C++/cli