build(win): export extern symbols for use in FFI #22756

Makes `extern` variables accessible through ffi on Windows.

Follow-up to https://github.com/neovim/neovim/pull/15999
This commit is contained in:
luukvbaal
2023-03-23 12:58:50 +01:00
committed by GitHub
parent 4e4203f71b
commit b02880593e
2 changed files with 15 additions and 1 deletions

View File

@@ -1,7 +1,12 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check // This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#define EXTERN // Make sure extern symbols are exported on Windows
#ifdef WIN32
# define EXTERN __declspec(dllexport)
#else
# define EXTERN
#endif
#include <assert.h> #include <assert.h>
#include <limits.h> #include <limits.h>
#include <msgpack/pack.h> #include <msgpack/pack.h>

View File

@@ -63,5 +63,14 @@ describe('ffi.cdef', function()
nil nil
) )
]=]) ]=])
-- Check that extern symbols are exported and accessible
eq(true, exec_lua[[
local ffi = require('ffi')
ffi.cdef('uint64_t display_tick;')
return ffi.C.display_tick >= 0
]])
end) end)
end) end)