Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Using std::regex causes plugin loading to fail — is there an alternative?

    Plugin Development
    4
    4
    118
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Coises
      Coises last edited by

      While working on a plugin using Visual Studio 2022, I noticed that when I added some std::regex code, the plugin build was successful but Notepad++ could not load it. Removing the std::regex code made it work again.

      I’m guessing this has something to do with the statement in build . md of Notepad++ that “Notepad++ is always built with Boost regex PCRE support instead of default c++11 regex ECMAScript used by plain Scintilla.” But the implications of that are beyond my understanding of C++ linkage and libraries.

      Is there a way to use regular expressions in a C++ plugin for Notepad++? For my purposes, it probably doesn’t have to be std::regex, though I’ve never used the Boost libraries and have no idea how they work.

      R 1 Reply Last reply Reply Quote 0
      • R
        rdipardo @Coises last edited by rdipardo

        I’m guessing this has something to do with the statement in build . md of Notepad++ that “Notepad++ is always built with Boost regex PCRE support instead of default c++11 regex ECMAScript used by plain Scintilla.”

        Boost is just the regex engine for the editor’s find & replace capabilities. There’s no requirement to use any Boost APIs in a plugin. (You would have to copy the Boost header files into your own project to make that possible).

        Removing the std::regex code made it work again.

        The reason why is basically what you quoted from BUILD.md. Notepad++ “turns off” C++11’s builtin regex support in favour of Boost, as explained here:

        The C++11 <regex> support may be disabled by compiling Scintilla with NO_CXX11_REGEX defined.

        and here:

        A simple interface provides support for switching the Regular Expressions engine at compile time.
        . . .

        Preprocessors affect building

        Preprocessor Description
        NO_CXX11_REGEX Build Scintilla without C++11 std::regex.

        Is there a way to use regular expressions in a C++ plugin for Notepad++?

        Scintilla’s APIs may be enough to get the job done, even if they are “limited and should only be used for simple cases and initial development”.

        1 Reply Last reply Reply Quote 2
        • Derek Brown
          Derek Brown last edited by Derek Brown

          You could try using re2, which is a regex engine by Google, much faster than std::regex, and is available in vcpkg. I have used it in a plugin myself.

          All of Boost is also available in vcpkg, so if you’re unsure how to install Boost that is the best way to go.

          It is pretty easy to set up vcpkg for use with Visual Studio, if you haven’t already. If you have trouble, I can provide some help, but give it a try first.

          Alan Kilborn 1 Reply Last reply Reply Quote 2
          • Alan Kilborn
            Alan Kilborn @Derek Brown last edited by

            @Derek-Brown said in Using std::regex causes plugin loading to fail — is there an alternative?:

            easy to set up vcpkg for use with Visual Studio, if you haven’t already. If you have trouble, I can provide some help

            I’d think there might be better, more on-topic, forums for that, but let’s see how it goes.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Copyright © 2014 NodeBB Forums | Contributors