Skip to content
⌘ NSIS Forum Archive

Issue when building plugin in Borland 5.5

3 posts

parasoul#

Issue when building plugin in Borland 5.5

Hi,
I'm having a very strange issue when building a plugin in Borland 5.5

Here's some simplified code to illustrate the issue:

#include "nsis_ansi\pluginapi.h"
#define NSISFUNC(name) extern "C" void __declspec(dllexport) name(HWND hWndParent, int string_size, char* variables, stack_t** stacktop, extra_parameters* extra)
extra_parameters* ep;
HANDLE g_hInstance;
extern volatile stack_t **g_stacktop;
extern volatile char *g_variables;
int cool()
{
    int i = 0;
    return i;
}
NSISFUNC(str_length)
{
MessageBox(0,"Hi!",0,0);
cool();
ExitProcess(0);
} 
For some reason, when I call other functions within the plugin, NSIS either does not execute the plugin function correctly, or the plugin function is corrupted in some way, because nothing happens.

Calling WinAPI functions work fine.

With this code:

#include "nsis_ansi\pluginapi.h"
#define NSISFUNC(name) extern "C" void __declspec(dllexport) name(HWND hWndParent, int string_size, char* variables, stack_t** stacktop, extra_parameters* extra)
extra_parameters* ep;
HANDLE g_hInstance;
extern volatile stack_t **g_stacktop;
extern volatile char *g_variables;
int cool()
{
    int i = 0;
    return i;
}
NSISFUNC(str_length)
{
MessageBox(0,"Hi!",0,0);
ExitProcess(0);
} 
(not calling the function cool()), it executes perfectly and I see the messagebox.

I tried changing the calling convention of the function to cdecl,stdcall, nothing has worked.

Current build options: -u- (not include _ symbol before symbol names), -g0 (ignore max # of warnings in code)

Any ideas?
Anders#
We don't do any testing with Borland so you might be a bit on your own. Why not use a free version of MSVC or MinGW? If we were to officially support a third compiler it would probably be clang. This does not mean you cannot continue using whatever compiler you want but you are less likely to get helpful suggestions.

In the define after __declspec(dllexport), add __cdecl. If it still is buggy, try stepping into the function in a debugger and make sure the stack is OK.

Don't call ExitProcess in a plugin, it will leave junk in %temp%. You can post WM_CLOSE to hwndParent or something like that or just add Quit to your .nsi after the plugin call...
parasoul#
Thanks Anders 😁

Apparently it was an issue with CodeBlocks because when I installed C++ Builder from Borland directly, everything went fine.

Thanks again!