I'm trying to make a new plugin for N++. Using 4.1.2. I keep getting the message "FuncItems array is not set correctly".
I don't know if everybody here uses VS, but I'm compiling with gcc, I'm not a fan of C++. After struggling for a while, I tried to compile the plugin example instead, NppInsertPlugin.
At first, I was getting undefined references to operators new and delete. I changed the makefile: gcc -> g++. Compiled without a warning, nut N++ still kept refusing the plugin. gcc / G++ are 3.4.5.
Actually I didn't use NppInsertPlugin, but NppPluginDemo whitch is available on the french version of the plugin howto page (and not on the english version, i just noticed)
Ok, I figured it out. DLL_PROCESS_ATTACH never gets called, so structure is still uninitialized when N++ calls getFuncsArray(). In fact, DllMain doesn't get called at all. Looking at the plugin example, this looks like a bug to me. Don?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I had the same error message ("FuncItems array is not set correctly"). I finally found my error, I don't know if your problem is the same. Here is what I did :
I used the demo project "NPPDemoPlugin". At first it didn't work because that project seems to be outdated :
- first there is now 5 mandatory functions and not 4 as in that demo project. So I added the "messageProc" function that was needed.
Then I had the error message about FuncItems. In my case, DLL_PROCESS_ATTACH is correctly called. I noticed then that the structure "FuncItem" has changed too : it now have a new field "ShortcutKey *_pShKey;". I fixed that and the message didn't come again. I hope it will solve your problem too.
Here are the changes I maked in the file "PluginInterface.h" :
typedef struct {
char _itemName[itemNameMaxLen];
PFUNCPLUGINCMD _pFunc;
int _cmdID;
bool _init2Check;
ShortcutKey *_pShKey; //--> the new field
} FuncItem;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for posting, but I already had the _pShKey field. It is present in the PluginInterface.h, NppInsertPlugin.zip that I downloaded. Perhaps you had an older version of NppInsertPlugin.zip?
Anyway, the problem was solved for me when I posted 2007-08-11. I simply put the initialization elsewhere, where it executes before getFuncsArray() returns. N++ accepted the plugin then.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi.
I'm trying to make a new plugin for N++. Using 4.1.2. I keep getting the message "FuncItems array is not set correctly".
I don't know if everybody here uses VS, but I'm compiling with gcc, I'm not a fan of C++. After struggling for a while, I tried to compile the plugin example instead, NppInsertPlugin.
At first, I was getting undefined references to operators new and delete. I changed the makefile: gcc -> g++. Compiled without a warning, nut N++ still kept refusing the plugin. gcc / G++ are 3.4.5.
After that, I stripped the file to bare minimum:
void insertCurrentFullPath()
{
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD reasonForCall,
LPVOID lpReserved )
{
switch (reasonForCall)
{
case DLL_PROCESS_ATTACH:
{
funcItem[0]._pFunc = insertCurrentFullPath;
strcpy(funcItem[0]._itemName, "Current Full Path");
funcItem[0]._init2Check = false;
funcItem[0]._pShKey = NULL;
}
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
extern "C" __declspec(dllexport) void setInfo(NppData notpadPlusData)
{
nppData = notpadPlusData;
}
extern "C" __declspec(dllexport) const char * getName()
{
return "name";
}
extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *nbF)
{
*nbF = 1;
return funcItem;
}
extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
{
}
extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
return TRUE;
}
Compiled fine with both gcc and g++. N++ still refuses the plugin with "FuncItems array is not set correctly". Help?
Actually I didn't use NppInsertPlugin, but NppPluginDemo whitch is available on the french version of the plugin howto page (and not on the english version, i just noticed)
http://notepad-plus.sourceforge.net/commun/misc/NppPluginDemo.zip
...and that demo plugin is indeed outdated.
Not sure (never written any C/C++), but shouldn't
extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *nbF)
{
*nbF = 1;
return funcItem;
}
do a
return funcItem[0];
instead?
Nope, we need to return an address there. return funcItem is roughly equal to return &funcItem[0] and is correct. Thanks for replying, though.
Ok, I figured it out. DLL_PROCESS_ATTACH never gets called, so structure is still uninitialized when N++ calls getFuncsArray(). In fact, DllMain doesn't get called at all. Looking at the plugin example, this looks like a bug to me. Don?
I had the same error message ("FuncItems array is not set correctly"). I finally found my error, I don't know if your problem is the same. Here is what I did :
I used the demo project "NPPDemoPlugin". At first it didn't work because that project seems to be outdated :
- first there is now 5 mandatory functions and not 4 as in that demo project. So I added the "messageProc" function that was needed.
Then I had the error message about FuncItems. In my case, DLL_PROCESS_ATTACH is correctly called. I noticed then that the structure "FuncItem" has changed too : it now have a new field "ShortcutKey *_pShKey;". I fixed that and the message didn't come again. I hope it will solve your problem too.
Here are the changes I maked in the file "PluginInterface.h" :
added :
struct ShortcutKey {
bool _isCtrl;
bool _isAlt;
bool _isShift;
unsigned char _key;
};
extern "C" __declspec(dllexport) void messageProc(UINT Message, WPARAM wParam, LPARAM lParam);
changed :
typedef struct {
char _itemName[itemNameMaxLen];
PFUNCPLUGINCMD _pFunc;
int _cmdID;
bool _init2Check;
ShortcutKey *_pShKey; //--> the new field
} FuncItem;
Thanks for posting, but I already had the _pShKey field. It is present in the PluginInterface.h, NppInsertPlugin.zip that I downloaded. Perhaps you had an older version of NppInsertPlugin.zip?
Anyway, the problem was solved for me when I posted 2007-08-11. I simply put the initialization elsewhere, where it executes before getFuncsArray() returns. N++ accepted the plugin then.