Using C++ standard library in Notepad++ plugins.
-
I’m a complete newbe at plugin programming and have lots of things to learn. Lots, lots, tons of things!!
Now I wonder if it’s safe to use the C++ standard library in my plugins. Will another user be able to run the plugin if he hasn’t a C++ toolchain installed? Would I have to statically link the standard library and the C/C++ runtime or would Visual Studio do this for me by default?
How do you do? Do you call std:: functions in your plugins or do you avoid them?
-
Notepad++ is compiled with static linking, and it’s best to do that for plugins as well. Right-click the project, select Properties, then C++ > Code Generation and set Runtime Library to /MT for Release builds and /MTd for debug builds.
If you use the official plugin template, the supplied solution file already sets static linking.
Note that this is OK because Notepad++ and plugins never pass C++ objects between one another. The plugin API is a pure C interface.
The only time this might cause a problem is if your DLL links further DLLs which were compiled with dynamic linking.
A side note: you might want to take a look at a project I created, NppCppMSVS: Visual Studio Project Template for a Notepad++ C++ Plugin. It’s a template you can add to Visual Studio so that you can easily start a new plugin project directly from Visual Studio. As noted in the readme, This project is not a part of Notepad++ and is not endorsed by the author of Notepad++. With that understanding, you might want to take a look at its documentation and see if you think it would be an easier place to start than the official plugin template (which is a GitHub template, not a Visual Studio template).
-
If you find C++ overwhelming (like I do), you might want to give NppCSharpPluginPack a try, since it’s built in C#. I maintain it myself, and I can vouch that it works pretty well. If you use JsonTools or HugeFiles, those plugins are more or less based on that template.
I think that C++ is a much better bet if you feel confident in your ability to write memory-safe C++, but if you feel anxious about not having a garbage collector, NppCSharpPluginPack is a good option.
There’s also PythonScript, which is probably not a great choice for any plugin that requires heavy computation due to Python being a slow language, but is quite nice for small scripts.
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