如何检测函数是否执行IO操作
How to detect if a function performs IO operations?
有没有可以查找的指标来了解函数是否执行I/O操作?主要的目标平台是Linux(Ubuntu,或者它的一些变体(。
最明显的方法是有一个这样的函数/库的目录,并检查其中是否存在函数。然而,我想知道如何首先构建这样的目录。
例如,printf
最终会写入标准输出,因此它会计数。从USB端口读取的功能也会起作用。但他们有什么共同点吗,即使我必须挖掘到最底层?
这可能与问题无关,但理想情况下,我可以利用这些函数的某些模式,以便使用工具自动识别它们。我只是不确定该寻找什么低级指令。
标准C++当然没有从USB读取的函数,但让我们暂时忽略这个细节。
哪些函数执行"真实"I/O的问题可以在标准C++中通过询问哪些库函数具有可观察的副作用来近似。这直接指向一组输入/输出头,当然现在还有<filesystem>
。
(从C++引用复制:(
<iosfwd> forward declarations of all classes in the input/output library
<ios> std::ios_base class, std::basic_ios class template and several typedefs
<istream> std::basic_istream class template and several typedefs
<ostream> std::basic_ostream, std::basic_iostream class templates and several typedefs
<iostream> several standard stream objects
<fstream> std::basic_fstream, std::basic_ifstream, std::basic_ofstream class templates and several typedefs
<sstream> std::basic_stringstream, std::basic_istringstream, std::basic_ostringstream class templates and several typedefs
<syncstream> (since C++20) std::basic_osyncstream, std::basic_syncbuf, and typedefs
<strstream> (deprecated) std::strstream, std::istrstream, std::ostrstream
<iomanip> Helper functions to control the format of input and output
<streambuf> std::basic_streambuf class template
<cstdio> C-style input-output functions
相关文章:
- 无论条件是否为true,if总是在c++中执行
- 是否可以依赖函数范围的静态变量来执行程序关闭期间调用的方法?
- 释放动态分配的内存时是否需要执行此额外步骤
- 是否可以在命令行中将输入参数传递给可执行文件
- 如果 C 函数仍然可以间接执行(通过回调函数),那么将它声明为静态函数是否是一种不好的做法?
- 如果包含映射的静态库与可执行文件和动态库链接,静态映射(变量)是否会被多次释放?
- 是否可以将具有不同签名的 lambda 存储在 std::vector 中并在函数中执行它们(使用各自的参数)?
- 如何检查参数包是否具有执行顺序中的确切类型
- 在类内和类外的定义处执行类转发声明是否有区别
- 如何检测函数是否执行IO操作
- 检查子类是否执行了方法重写
- Visual Studio 2010 是否执行零初始化
- cv::P oint3f 赋值运算符是否执行"深度"复制?
- 重复Handle()是否执行任何解释性通信(IPC),如果不是为什么目标参数
- SSL是否执行自动重新谈判
- 从另一个成员函数/构造函数调用C++构造函数是否执行初始值设定项列表
- 在线编译器工具是否执行所有操作,或者它们只是检查是否编译
- std::make_shared是否执行值初始化(GCC和clang不同意)
- shared_ptr的删除程序是否执行任何同步?
- 是否执行decltype内的表达式,或者只是检查是否验证