Skip to main content

nsis_plugin

Macro nsis_plugin 

Source
macro_rules! nsis_plugin {
    () => { ... };
    (std) => { ... };
}
Expand description

Declares the crate to be an NSIS plug-in DLL. Invoke exactly once.

Generates the DllMain that stashes the module handle, a #[panic_handler] that terminates rather than unwinding into the exehead, and a #[global_allocator] on the process heap so the DLL links without a C runtime.

Everything it emits is gated on target_os = "windows", so a plug-in crate still cargo checks and cargo clippys on macOS and Linux. Pair it with #![cfg_attr(target_os = "windows", no_std)].

ⓘ
nsis_plugin!();       // no_std: panic handler and allocator included
nsis_plugin!(std);    // std build: only DllMain

A std build links the C runtime, which owns the PE entry point (DllMainCRTStartup), initialises itself and then calls DllMain. So the std form defines DllMain instead; defining the entry point too is a duplicate symbol.