1

I noticed that when I use xp::sregex::compile in my code, the string ...\3rdparty\boost-1_58\boost/xpressive/detail/core/matcher/regex_byref_matcher.hpp (with my local path) appears in the binary code, compiled in release mods. Is there a way to remove it?

sehe
  • 374,641
  • 47
  • 450
  • 633
tzviya
  • 537
  • 1
  • 4
  • 14

1 Answers1

1

This is undoubtedly when the code uses __FILE__ to get nice assert/exception messages.

The only place where Xpressive uses it directly is in regex_error.hpp:

#define BOOST_XPR_ENSURE_(pred, code, msg)                                                          \
    boost::xpressive::detail::ensure_(!!(pred), code, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)  \
    /**/

You could easily hack it to be

#include <boost/xpressive/regex_error.hpp>

#undef BOOST_XPR_ENSURE_

#define BOOST_XPR_ENSURE_(pred, code, msg)                                                          \
    boost::xpressive::detail::ensure_(!!(pred), code, msg, BOOST_CURRENT_FUNCTION, "(source-hidden)", __LINE__)  \
    /**/

Keep in mind:

  • the hack needs to go before any other Xpressive includes
  • this will limit the usefulness of the messages, should they occur
  • there is a possibility that one of the libraries that Xpressive depends on uses similar constructs
sehe
  • 374,641
  • 47
  • 450
  • 633
  • please post a [SSCCE](http://sscce.org/)/[MCVE](http://stackoverflow.com/help/mcve) – sehe Mar 02 '16 at 08:13
  • Thanks, it makes sense, I tried it but I still get the path of regex_byref_matcher.hpp in the binary, and I don't see the string "source-hidden" instead. Also it compiled successfully with only the undef so it didnt really meet this macro. – tzviya Mar 02 '16 at 08:52