Community
    • Login

    Npp Plugin - failing when "string" type is used

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    4 Posts 2 Posters 59 Views 2 Watching
    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.
    • medvidecM Offline
      medvidec
      last edited by

      Hello,

      I am trying to resurrect the NppVerilog plugin, compiling it with MinGW - x86_64-w64-mingw32-g++ (x86_64-posix-seh-rev1, Built by MinGW-Builds project) 16.1.0.

      I actually reached the point where adding global variable “const string configFile = “/plugins/config/verilogConfig.txt”;” variable makes the plugin twice as bigger, unusable and refused by NPP (“The specified module cound not be found. DLL is not compatible…” etc.) while “const char configFile[] = “/plugins/config/verilogConfig.txt”;” is loaded by NPP without any issue.

      Is something like this know ? Mz NPP version is 8.6.4 - not the newest one but not too old either.

      Thank you for help.

      PeterJonesP 2 Replies Last reply Reply Quote 0
      • PeterJonesP Offline
        PeterJones @medvidec
        last edited by PeterJones

        @medvidec ,

        I would normally ask that you check to make sure that your compiler’s bitness matches your N++ bitness (since I forget MinGW’s official naming scheme), but given that it works when you use const char configFile[], you’ve presumably got that all worked out.

        There’s nothing specific about string which makes a plugin incompatible with N++ – or, at least, I use std::string and std::wstring throughout my MSVC-based plugins all the time. There shouldn’t be any difference in syntax for strings betwen MSVC and MinGW.

        But std::string isn’t 100% drop-in replacement for char*: if you are passing to an API that requires char* (+), you would need to switch to configFile.c_str() or configFile.data() where the char* version of the variable just used configFile. So that would be the first avenue of exploration I’d go down in debugging – seeing whether the function calls that are using configFile are compatible with string, or whether you need to extract the raw c-style pointer out of the std::string object.

        (And having to build the std::string interface in the DLL, vs being able to use pure-c++ char-manipulation could increase the DLL size significantly, so depending on the size of your plugin, that could “double” it.)

        +: The N++ plugin-communication messages are almost all wchar_t*-based (with one or two char*), not std::string based. Because of that, I am assuming you never passed the const char configFile[] to a N++ message without conversion, so I don’t think it’s the NPP API that’s causing the problem. But there are a lot of win32 API calls that require char* or wchar_t*, so passing in a string or wstring to one of those would not work, and you’d instead

        medvidecM 1 Reply Last reply Reply Quote 1
        • PeterJonesP Offline
          PeterJones @medvidec
          last edited by

          @medvidec said:

          NPP version is 8.6.4 - not the newest one but not too old either.

          I mean, that was from Feb 2024 (more than two years ago), and there’s been roughly 35 newer versions released in the intervening time. In software, 2+ years is ancient.

          That’s almost-definitely not the cause of your problem in this instance, but there have been a large number of important security fixes over that period, and choosing to not upgrade means your Notepad++ version has known and published security vulnerabilities (with exploits active in the wild), so it is much less secure than a modern Notepad++ version.

          1 Reply Last reply Reply Quote 1
          • medvidecM Offline
            medvidec @PeterJones
            last edited by

            @PeterJones said:

            I am assuming you never passed the const char configFile[] to a N++ message.

            I do not pass the string anywhere and it already affects the plugin acceptance. It is just declared and that is all. It might be some bug in MinGW itself but I am not able to judge. If I remove the initialization and have static const string configFile; the plugin is ok, too.

            In the meantime I upgraded to version 8.9.6.4 (the newest one) but it behaves the same.

            Is there a way how to debug what is going wrong when plugin is opened ?

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors