[mlpack-svn] [MLPACK] #155: order of includes and include protections
MLPACK Trac
trac at coffeetalk-1.cc.gatech.edu
Fri Oct 28 14:38:32 EDT 2011
#155: order of includes and include protections
--------------------------------------------------+-------------------------
Reporter: nslagle | Owner:
Type: wishlist | Status: new
Priority: major | Milestone:
Component: MLPACK | Resolution:
Keywords: includes, templates, style, nitpick | Blocking:
Blocked By: |
--------------------------------------------------+-------------------------
Comment (by nslagle):
A better way to guard against improper inclusion is to define a macro in
the standard ''.hpp'' as follows:
{{{
#ifndef DO_STUFF_EVER_HPP
#define DO_STUFF_EVER_HPP
class DoStuffEver
{
...
};
#define USE_DO_STUFF_EVER_IMPL
#include "do_stuff_ever_impl.hpp"
#undef USE_DO_STUFF_EVER_IMPL
#endif
}}}
In the ''do_stuff_ever_impl.hpp'', add a check for the single use
''#define'' from above:
{{{
#ifndef DO_STUFF_EVER_HPP
#ifndef USE_DO_STUFF_EVER_IMPL
#error "Do not include this file directly."
#endif
#endif
#ifndef DO_STUFF_EVER_IMPL_HPP
#define DO_STUFF_EVER_IMPL_HPP
...
#endif
}}}
--
Ticket URL: <http://trac.research.cc.gatech.edu/fastlab/ticket/155#comment:2>
MLPACK <www.fast-lab.org>
MLPACK is an intuitive, fast, and scalable C++ machine learning library developed by the FASTLAB at Georgia Tech under Dr. Alex Gray.
More information about the mlpack-svn
mailing list