go-pdfium icon indicating copy to clipboard operation
go-pdfium copied to clipboard

Add dll export to the callback functions.

Open jeroen1602 opened this issue 2 months ago • 0 comments

I was having issues tyring to build this project for windows. It was complaining that the callback functions have already been defined and can thus not add the dllexport attribute.

Here is an example error:

cgo-gcc-export-header-prolog:123:40: error: redeclaration of 'go_formfill_FFI_GetPage_cb' cannot add 'dllexport' attribute
  123 | extern __declspec(dllexport) FPDF_PAGE go_formfill_FFI_GetPage_cb(FPDF_FORMFILLINFO* me, FPDF_DOCUMENT document, int nPageIndex);
      |                                        ^
fpdf_formfill.go:16:18: note: previous declaration is here
   16 | extern FPDF_PAGE go_formfill_FFI_GetPage_cb(struct _FPDF_FORMFILLINFO *this, FPDF_DOCUMENT document, int nPageIndex);

I go this problem when using the zig (cross) compiler and clang (running native on Windows).

So I made a change to add the dllexport required to the first definitions of these methods when targeting windows.

Using this I did get it to compile for Windows.

jeroen1602 avatar Oct 06 '25 13:10 jeroen1602