我不想創建另一個自行車,並搜索輕量級(不boost,poco,ace或其他庫)crossplatform(win/lin)包裝下的管道/ popen C++。有什麼建議麼?Crossplatform輕質包裝管/ popen
1
A
回答
3
也許像
#ifndef _WIN32
inline int _pipe(int fildes[2], unsigned psize, int textmode) {
return pipe(fildes);
}
inline FILE* _popen(const char* command, const char* type) {
return popen(command, type);
}
inline void _pclose(FILE* file) {
pclose(file);
}
#endif
MSDN說_popen,_pclose和_pipe在CRT中提供。因此,我們只是將強調的函數轉發到Windows以外的真正POSIX函數(您可以做相反的事情,但請注意,_pipe需要2個額外的參數,這在Windows中是有意義的)。
___________
/ \
| Warning ! |
\___________/
|
-------- [email protected] [email protected] | [email protected] [email protected] [email protected]
----- _`\<,_ _`\<,_ _`\<,_ _`\<,_ _`\<,_
---- (*)/ (*) (*)/ (*) (*)/ (*) (*)/ (*) (*)/ (*)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
這些功能只能在控制檯程序中使用。它在Windows GUI程序中不起作用。有關詳細信息,請參閱_popen的MSDN頁面中的註釋,另請參閱What is the equivalent to Posix popen() in the Win32 API?。
你知道popen在shell中執行命令嗎? UNIX shell與Windows命令提示符之間的語法大不相同,並且這些不能通過一些pope/pclose的跨平臺實現來解決。
Windows函數與真正的POSIX函數之間可能存在一些細微的差別,但這些函數不是用這些簡單的包裝器處理的。
你不能在WinRT中使用它們。
(該自行車從http://www.chris.com/ascii/index.php?art=transportation%2Fbicycles複製。)
相關問題
- 1. C++的Crossplatform Sqlite3包裝器
- 2. Preproious Popen管道
- 3. 可可輕質字符串
- 4. OpenAL for CrossPlatform Development
- 5. c#crossplatform UserControl
- 6. xamarin crossplatform canvas
- 7. Xna GameEngine for crossplatform
- 8. 避免在輕量級Java遊戲重裝質地圖書館
- 9. 管道popen stderr和stdout
- 10. CrossPlatform上的信息
- 11. C++ popen()包裝器不適用於Objective-C++ for iPhone
- 12. 純託管SQLite NET包裝
- 13. 包裝pyspark管道.__ init__和裝飾器
- 14. 如何(輕鬆地)將C++函數包裝成易於安裝的R'包'
- 15. 不包括在內的包裝導管
- 16. PhoneGap Text to Speach(CrossPlatform)插件
- 17. 如何用管道執行python Popen?
- 18. 將stdin重定向到管道(popen)C++
- 19. 使用popen的非阻塞管道?
- 20. POPEN管減慢其他線程
- 21. Python grep和管道通過Popen
- 22. 是輕便的posix管?
- 23. 用子進程裝飾CLI程序.Popen
- 24. vmware如何輕鬆安裝?
- 25. php cli popen()包含文件一次?
- 26. 有沒有這些功能的輕量級JDBC包裝?
- 27. 使用ember.js和ember輕鬆地包裝引導/ jquery小部件
- 28. 如何輕鬆地從包裝容器中脫出?
- 29. 終端的輕量級事件包裝器
- 30. 爲Media Foundation生成託管包裝
啊,這是最簡單的方式Ç。我發現了一些現代的C++實現,包括重定向輸出特性,錯誤處理等。我想創建易於使用的機制來在單獨的進程中運行任何語句(因爲語句可以壓縮應用程序)並分析輸出和返回代碼。在做之前,我想環顧四周。 – Torsten
@Torsten:那會是什麼實現?你能鏈接到它嗎? –
@suluke對不起,我弄糊塗了:p。 – Stargateur