U
uli
Hi all!
I'm posting to both newsgroups, because it's actually a C++ problem but
could be that some of you using Matlab-&-MEX-&-C++ was struggling with the
same problem.
I'm trying to rewrite some Matlab routines in C++ for reusing them
identically in Matlab and some other simulation tools. For computational
algebra I want to use the Matrix Template Library (MTL,
http://www.osl.iu.edu/research/mtl/) which is written in C++ and therefore
makes use of std::cout.
I have to use the mexfunction-interface of Matlab to run C++ code within a
Matlab simulation. Since I'm writing my code with MSVC++ 6.0 and running
Matlab on Windows, together with MATLAB and MEX, I can't use "cout" but
"printf" ('cause of the MSWindows specific Matlab-Terminal).
However to come to my Problem now:
To solve this I want to redefine std::cout (within a header of my individual
MEXinterface.cpp) so that it makes use of printf() instead . Could someone
give me some hints or links to information how I could manage this?
I know that it must be tricky since cout prints stream?! So I need to
transform the stream in strings??
Perhaps as a last resort, if it can't be done, any "std::cout << ... "
should print a infomessage.
I know it's not a good way to redefine some functions of the std namespace.
I have never done something like this. But it seems to me to be the only way
out. I also just want to use this redefinition together with Matlab-&-MEX
and probably won't make much use of MTL specific printouts...
thanx a lot of for any kind of help!
regards,
uli
I'm posting to both newsgroups, because it's actually a C++ problem but
could be that some of you using Matlab-&-MEX-&-C++ was struggling with the
same problem.
I'm trying to rewrite some Matlab routines in C++ for reusing them
identically in Matlab and some other simulation tools. For computational
algebra I want to use the Matrix Template Library (MTL,
http://www.osl.iu.edu/research/mtl/) which is written in C++ and therefore
makes use of std::cout.
I have to use the mexfunction-interface of Matlab to run C++ code within a
Matlab simulation. Since I'm writing my code with MSVC++ 6.0 and running
Matlab on Windows, together with MATLAB and MEX, I can't use "cout" but
"printf" ('cause of the MSWindows specific Matlab-Terminal).
However to come to my Problem now:
To solve this I want to redefine std::cout (within a header of my individual
MEXinterface.cpp) so that it makes use of printf() instead . Could someone
give me some hints or links to information how I could manage this?
I know that it must be tricky since cout prints stream?! So I need to
transform the stream in strings??
Perhaps as a last resort, if it can't be done, any "std::cout << ... "
should print a infomessage.
I know it's not a good way to redefine some functions of the std namespace.
I have never done something like this. But it seems to me to be the only way
out. I also just want to use this redefinition together with Matlab-&-MEX
and probably won't make much use of MTL specific printouts...
thanx a lot of for any kind of help!
regards,
uli