New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some headers fail to compile independently #150

Closed
tonyelewis opened this Issue Aug 24, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@tonyelewis

tonyelewis commented Aug 24, 2018

I think the previously-fixed Trac ticket #12228 has regressed.

The Boost Header Policy requires:

Make sure that a translation unit consisting of just the contents of the header file will compile successfully.

Yet, I'm seeing compile errors for quite a few of the headers under Clang and GCC. Eg for boost/test/data/monomorphic/initializer_list.hpp:

boost/test/data/monomorphic/initializer_list.hpp:45:27: error: no type named 'vector' in namespace 'std'
    typedef typename std::vector<T>::const_iterator iterator;
            ~~~~~~~~~~~~~~^~~~~~
boost/test/data/monomorphic/initializer_list.hpp:45:33: error: expected member name or ';' after declaration specifiers
    typedef typename std::vector<T>::const_iterator iterator;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
boost/test/data/monomorphic/initializer_list.hpp:64:5: error: unknown type name 'iterator'
    iterator        begin() const   { return m_data.begin(); }
    ^
boost/test/data/monomorphic/initializer_list.hpp:68:10: error: no template named 'vector' in namespace 'std'
    std::vector<T> m_data;
    ~~~~~^
boost/test/data/monomorphic/initializer_list.hpp:79:18: error: no template named 'vector' in namespace 'std'
    typedef std::vector<bool>::const_iterator iterator;
            ~~~~~^
boost/test/data/monomorphic/initializer_list.hpp:79:32: error: non-friend class member 'const_iterator' cannot have a qualified name
    typedef std::vector<bool>::const_iterator iterator;
                             ~~^
boost/test/data/monomorphic/initializer_list.hpp:79:32: error: typedef declarator cannot be qualified
    typedef std::vector<bool>::const_iterator iterator;
                             ~~^
boost/test/data/monomorphic/initializer_list.hpp:79:46: error: expected ';' at end of declaration list
    typedef std::vector<bool>::const_iterator iterator;
                                             ^
                                             ;
boost/test/data/monomorphic/initializer_list.hpp:96:5: error: unknown type name 'iterator'
    iterator        begin() const   { return m_data.begin(); }
    ^
boost/test/data/monomorphic/initializer_list.hpp:100:10: error: no template named 'vector' in namespace 'std'
    std::vector<bool> m_data;
    ~~~~~^
10 errors generated.

I think there are problems compiling the following 20 headers:

  • boost/test/data/dataset.hpp
  • boost/test/data/monomorphic/delayed.hpp
  • boost/test/data/monomorphic/grid.hpp
  • boost/test/data/monomorphic.hpp
  • boost/test/data/monomorphic/initializer_list.hpp
  • boost/test/data/monomorphic/join.hpp
  • boost/test/data/monomorphic/zip.hpp
  • boost/test/data/test_case.hpp
  • boost/test/tools/collection_comparison_op.hpp
  • boost/test/tools/detail/lexicographic_manip.hpp
  • boost/test/tools/detail/per_element_manip.hpp
  • boost/test/tree/test_case_template.hpp
  • boost/test/utils/runtime/argument_factory.hpp
  • boost/test/utils/runtime/cla/argv_traverser.hpp
  • boost/test/utils/runtime/cla/parser.hpp
  • boost/test/utils/runtime/env/fetch.hpp
  • boost/test/utils/runtime/finalize.hpp
  • boost/test/utils/runtime/modifier.hpp
  • boost/test/utils/runtime/parameter.hpp
  • boost/test/utils/xml_printer.hpp

Thanks for your continued work on this library.

@raffienficiaud

This comment has been minimized.

Member

raffienficiaud commented Sep 2, 2018

Hi,

Thanks for raising this again. How do you check if things are able to compile independently? Do you happen to have some magic compiler command? It would save me some time and I'll try to integrate that in the test process.

@dalg24

This comment has been minimized.

dalg24 commented Sep 3, 2018

To check that your header files are self-contained, you could check they work when included on their own.

#include YOUR_HEADER_HERE
int main() { return 0; }
@raffienficiaud

This comment has been minimized.

Member

raffienficiaud commented Sep 3, 2018

Yeah, but @dalg24 that would take me a day to check :)

@dalg24

This comment has been minimized.

dalg24 commented Sep 4, 2018

Not necessarily, you can probably inspire yourself from something like this chkhdr script.

@tonyelewis

This comment has been minimized.

tonyelewis commented Sep 8, 2018

I don't know of any way to get the compiler to check that each header it encounters compiles independently. However, I've sometimes scanned within a Boost repo to identify any such headers with a command like:

find ./include -iname '*.hpp' | sort | grep detail -vw | grep impl -v | xargs -I VAR clang++ -isystem include -isystem /opt/include -fsyntax-only -x c++ -o /tmp/a.o VAR

This is a good approach to manually trigger a search for any problems. But @dalg24's suggested approach of providing you with an automated way of detecting any future regressions.

@raffienficiaud

This comment has been minimized.

Member

raffienficiaud commented Sep 25, 2018

Fixed in develop via #161 . Thanks to all for your feedbacks and help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment