I did some deeper research. wrapping the nimbase.h would be wrong it is enough to wrap the TFrame stuff conditionally into a namespace Nim. In the generated code the wrapping should start after the #undef unix or before the first declaration until the end.
Would you accept a pull request when I try to do the change ? With my manual patches I can compile in debug and release mode, and the above code reduces to: import vcl/stdctrls, vcl/forms, vcl/sysutils, strutils {.this:self.} type TForm2* {.importcpp:"TForm2", header:"uFNimHelloCBuilder.h".} = object of TForm Button1*: ptr TButton Label1*: ptr TLabel TNotifyCode* = proc(self: ptr DelphiObject, sender: ptr DelphiObject) {.fastcall.} var counter = 0 proc myClick(self: ptr TForm2, sender: ptr DelphiObject) {.fastcall.} = Button1.Caption = "greetings from nim".capitalize proc test(self: ptr TForm2) {.exportc, fastcall.} = inc counter Button1.Caption = Button1.Caption & $counter var mycall: TMethod mycall.Data = self #var call: TNotifyCode = cast[TNotifyCode](myClick) mycall.Code = cast[TNotifyCode](myClick) Label1.OnClick := mycall