Home:ALL Converter>Is there anyway to figure out what STL header file has not been included directly?

Is there anyway to figure out what STL header file has not been included directly?

Ask Time:2013-09-17T13:49:18         Author:ZijingWu

Json Formatter

Our product uses C++ as the programming language. One annoying issue of using C++ STL is that we forget to include the necessary header files, because the file may have been included in some other STL header, the build passes. For example,

In Mac platform using Xcode, if I use std::auto_ptr without include memory.h but include iostream.h, the build will pass, but it will fail in Android platform.

But I don't want move the code to Android for an build check for each code change commit. So, is there anyway to avoid that problem?

Edit 1: I know the best solution is to not forget the include the header. But developers make mistakes. So is there any tool to help check it?

Edit 2: Seams no ideal solution, so I will use vim script to check it in my editor,the solution is similar to https://github.com/vim-scripts/vim-cpp-auto-include/blob/master/ftplugin/cpp_auto_include.vim

Author:ZijingWu,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/18842149/is-there-anyway-to-figure-out-what-stl-header-file-has-not-been-included-directl
Narek :

You can use a common_includes.h file that includes all necessary files there, and include that file everywhere you need. This will simplify the situation and will help out forgetting to include some file. At least you will forget it only one time :).",
2013-09-17T06:22:52
yy