简体   繁体   中英

How do you redirect a standard stream of a C++ routine wrapped with SWIG and exposed to Python?

Is it possible to control the standard streams of C++ code in python? The code is wrapped with SWIG and then exposed to Python where I call one of its functions.

I am getting all kinds of unwanted messages coming from C++ code and I want to suppress them either by not using the output stream or by redirecting it to a bit bucket, eg devnull from the os module.

我认为最好的方法是在扩展的C或C ++中实现一个简单的函数/方法来重定向stdout输出,例如,请参见dup ,我认为它将很好地工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM