Npp Plugin - failing when "string" type is used
-
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.
-
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
stringwhich makes a plugin incompatible with N++ – or, at least, I usestd::stringandstd::wstringthroughout my MSVC-based plugins all the time. There shouldn’t be any difference in syntax forstrings betwen MSVC and MinGW.But
std::stringisn’t 100% drop-in replacement forchar*: if you are passing to an API that requireschar*(+), you would need to switch toconfigFile.c_str() orconfigFile.data() where thechar*version of the variable just usedconfigFile. So that would be the first avenue of exploration I’d go down in debugging – seeing whether the function calls that are usingconfigFileare compatible withstring, or whether you need to extract the raw c-style pointer out of thestd::stringobject.(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 twochar*), notstd::stringbased. Because of that, I am assuming you never passed theconst 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 requirechar*orwchar_t*, so passing in astringorwstringto one of those would not work, and you’d instead -
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.
-
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 ?
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