Closed yanshouwang closed 3 months ago
I don't think FORCEINLINE
is a keyword. It's probably a macro defined by some windows header. You could try to find where it's defined and include that header, or just add a command line flag to your config yaml that defines it to be empty: -D FORCEINLINE=''
compiler-opts:
- '-D'
- "FORCEINLINE=''"
I'm not 100% sure that's the right way to define this macro (there's 2 layers of escaping here), but you can play around with it and see what works.
It doesn't work, I have no idea how to make this work.
The VersionHelpers.h
is defined like this
#ifdef __cplusplus
#define VERSIONHELPERAPI inline bool
#else // __cplusplus
#define VERSIONHELPERAPI FORCEINLINE BOOL
#endif // __cplusplus
VERSIONHELPERAPI
IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
{
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 };
DWORDLONG const dwlConditionMask = VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
VER_MINORVERSION, VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
osvi.dwMajorVersion = wMajorVersion;
osvi.dwMinorVersion = wMinorVersion;
osvi.wServicePackMajor = wServicePackMajor;
return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
}
It doesn't work, I have no idea how to make this work.
Can you be more specific? What did you try? What error are you seeing?
The
VersionHelpers.h
is defined like this
That's not defining FORCEINLINE
, it's using it. See if you can find where FORCEINLINE
is defined.
I can find the FORCEINLINE
define in winnt.h
, but the error still there after I add the winnt.h
to entry-point.
// winnt.h
#ifndef FORCEINLINE
#if (_MSC_VER >= 1200)
#define FORCEINLINE __forceinline
#else
#define FORCEINLINE __inline
#endif
#endif
I can fix it by add compile-opts like this.
compiler-opts:
- '-D'
- "FORCEINLINE=__inline"
But another error occured
Running in Directory: 'E:\hybrid_sdk\hybrid_core\hybrid_core_windows'
Input Headers: [C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\Windows.h, C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\WTypesbase.h, C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h]
[SEVERE] : Header C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h: Total errors/warnings: 19.
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:39:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:40:27: error: unknown type name 'WORD' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:40:47: error: unknown type name 'WORD' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:40:67: error: unknown type name 'WORD' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:57:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:63:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:69:1: error: unknown type name 'BOOL' [Semantic Issue]
...
No idea how to fix this, I already add the WTypesbase.h
header and add the typedefs
typedefs:
include:
- BOOL
- WORD
Does VersionHelpers.h
#include
the headers it needs? Maybe the issue is you're missing some include directories (the -I
clang flag).
No idea how to fix this, I already add the
WTypesbase.h
header and add the typedefs
The typedefs
are not relevant here. That affects which typedefs are code-genned, not how the source file is parsed. We haven't got to the code-gen stage yet.
Does VersionHelpers.h #include the headers it needs? Maybe the issue is you're missing some include directories (the -I clang flag).
I tried to add -I
options, but seems the arguments doesn't support path like this?
- '-IC:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared'
[SEVERE] : Header C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypes.h: Total errors/warnings: 3.
[SEVERE] : warning: Files: 'linker' input unused
[SEVERE] : warning: (x86)\Windows: 'linker' input unused
[SEVERE] : warning: Kits\10\Include\10.0.22621.0\shared: 'linker' input unused
[SEVERE] : Header C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\Windows.h: Total errors/warnings: 3.
[SEVERE] : warning: Files: 'linker' input unused
[SEVERE] : warning: (x86)\Windows: 'linker' input unused
[SEVERE] : warning: Kits\10\Include\10.0.22621.0\shared: 'linker' input unused
[SEVERE] : Header C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h: Total errors/warnings: 22.
[SEVERE] : warning: Files: 'linker' input unused
[SEVERE] : warning: (x86)\Windows: 'linker' input unused
[SEVERE] : warning: Kits\10\Include\10.0.22621.0\shared: 'linker' input unused
How can I declare -I
correctly?
Now my ffigen.yaml
is defined like this.
headers:
entry-points:
- 'C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\ntdef.h'
- 'C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypes.h'
- 'C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h'
# - 'C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\Windows.h'
# - 'src/hybrid_core_windows.h'
# include-directives:
# - 'src/hybrid_core_windows.h'
compiler-opts:
- '-I'
- '"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared"'
# - '-D'
# - "FORCEINLINE=__inline"
exclude-all-by-default: true
functions:
include:
- GetVersionExW
# - VerifyVersionInfoW
# - VerSetConditionMask
- IsWindows7OrGreater
- IsWindows7SP1OrGreater
- IsWindows8OrGreater
- IsWindows8Point1OrGreater
- IsWindowsServer
- IsWindowsVersionOrGreater
- IsWindowsVistaOrGreater
- IsWindowsVistaSP1OrGreater
- IsWindowsVistaSP2OrGreater
- IsWindowsXPOrGreater
- IsWindowsXPSP1OrGreater
- IsWindowsXPSP2OrGreater
- IsWindowsXPSP3OrGreater
Get errors below
Running in Directory: 'E:\hybrid_sdk\hybrid_core\hybrid_core_windows'
Input Headers: [C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\ntdef.h, C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypes.h, C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h]
[SEVERE] : Header C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\ntdef.h: Total errors/warnings: 2.
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\ntdef.h:197:2: error: "No Target Architecture" [User-Defined Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\ntdef.h:288:2: error: Must define a target architecture. [User-Defined Issue]
[SEVERE] : Header C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h: Total errors/warnings: 20.
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:39:1: error: unknown type name 'FORCEINLINE' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:39:17: error: expected ';' after top level declarator [Parse Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:57:1: error: unknown type name 'FORCEINLINE' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:57:17: error: expected ';' after top level declarator [Parse Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:63:1: error: unknown type name 'FORCEINLINE' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:63:17: error: expected ';' after top level declarator [Parse Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:69:1: error: unknown type name 'FORCEINLINE' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:69:17: error: expected ';' after top level declarator [Parse Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:75:1: error: unknown type name 'FORCEINLINE' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:75:17: error: expected ';' after top level declarator [Parse Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:81:1: error: unknown type name 'FORCEINLINE' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:81:17: error: expected ';' after top level declarator [Parse Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:87:1: error: unknown type name 'FORCEINLINE' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:87:17: error: expected ';' after top level declarator [Parse Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:93:1: error: unknown type name 'FORCEINLINE' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:93:17: error: expected ';' after top level declarator [Parse Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:99:1: error: unknown type name 'FORCEINLINE' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:99:17: error: expected ';' after top level declarator [Parse Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:105:1: error: unknown type name 'FORCEINLINE' [Semantic Issue]
[SEVERE] : fatal error: too many errors emitted, stopping now
[WARNING]: The compiler found warnings/errors in source files.
[WARNING]: This will likely generate invalid bindings.
[SEVERE] : Skipped generating bindings due to errors in source files. See https://github.com/dart-lang/native/blob/main/pkgs/ffigen/doc/errors.md.
Seems the VersionHelpers.h
missed some includes itself...
I added ignore-source-errors: true
to ffigen.yaml
. But inline functions seems not suported.
Running in Directory: 'E:\hybrid_sdk\hybrid_core\hybrid_core_windows'
Input Headers: [C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypes.h, C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h]
[SEVERE] : Header C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h: Total errors/warnings: 19.
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:39:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:40:27: error: unknown type name 'WORD' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:40:47: error: unknown type name 'WORD' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:40:67: error: unknown type name 'WORD' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:57:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:63:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:69:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:75:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:81:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:87:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:93:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:99:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:105:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:111:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:117:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:123:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:129:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:135:1: error: unknown type name 'BOOL' [Semantic Issue]
[SEVERE] : C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\VersionHelpers.h:144:1: error: unknown type name 'BOOL' [Semantic Issue]
[WARNING]: The compiler found warnings/errors in source files.
[WARNING]: This will likely generate invalid bindings.
[WARNING]: Ignored source errors. (User supplied --ignore-source-errors)
[WARNING]: No definition found for declaration - (Cursor) spelling: _TP_CALLBACK_INSTANCE, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _TP_CALLBACK_INSTANCE, usr: c:@S@_TP_CALLBACK_INSTANCE
[WARNING]: No definition found for declaration - (Cursor) spelling: _TP_POOL, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _TP_POOL, usr: c:@S@_TP_POOL
[WARNING]: No definition found for declaration - (Cursor) spelling: _TP_CLEANUP_GROUP, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _TP_CLEANUP_GROUP, usr: c:@S@_TP_CLEANUP_GROUP
[WARNING]: No definition found for declaration - (Cursor) spelling: _TP_WORK, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _TP_WORK, usr: c:@S@_TP_WORK
[WARNING]: No definition found for declaration - (Cursor) spelling: _TP_TIMER, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _TP_TIMER, usr: c:@S@_TP_TIMER
[WARNING]: No definition found for declaration - (Cursor) spelling: _TP_WAIT, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _TP_WAIT, usr: c:@S@_TP_WAIT
[WARNING]: No definition found for declaration - (Cursor) spelling: _TP_IO, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _TP_IO, usr: c:@S@_TP_IO
[WARNING]: No definition found for declaration - (Cursor) spelling: _TEB, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _TEB, usr: c:@S@_TEB
[WARNING]: No definition found for declaration - (Cursor) spelling: _PROC_THREAD_ATTRIBUTE_LIST, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _PROC_THREAD_ATTRIBUTE_LIST, usr: c:@S@_PROC_THREAD_ATTRIBUTE_LIST
[WARNING]: No definition found for declaration - (Cursor) spelling: _NDR_ASYNC_MESSAGE, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _NDR_ASYNC_MESSAGE, usr: c:@S@_NDR_ASYNC_MESSAGE
[WARNING]: No definition found for declaration - (Cursor) spelling: _NDR_CORRELATION_INFO, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _NDR_CORRELATION_INFO, usr: c:@S@_NDR_CORRELATION_INFO
[WARNING]: No definition found for declaration - (Cursor) spelling: NDR_ALLOC_ALL_NODES_CONTEXT, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct NDR_ALLOC_ALL_NODES_CONTEXT, usr: c:@S@NDR_ALLOC_ALL_NODES_CONTEXT
[WARNING]: No definition found for declaration - (Cursor) spelling: NDR_POINTER_QUEUE_STATE, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct NDR_POINTER_QUEUE_STATE, usr: c:@S@NDR_POINTER_QUEUE_STATE
[WARNING]: No definition found for declaration - (Cursor) spelling: _NDR_PROC_CONTEXT, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _NDR_PROC_CONTEXT, usr: c:@S@_NDR_PROC_CONTEXT
[WARNING]: No definition found for declaration - (Cursor) spelling: _PSP, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _PSP, usr: c:@S@_PSP
[WARNING]: No definition found for declaration - (Cursor) spelling: IEnumContextProps, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct IEnumContextProps, usr: c:@S@IEnumContextProps
[WARNING]: No definition found for declaration - (Cursor) spelling: IContext, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct IContext, usr: c:@S@IContext
[WARNING]: No definition found for declaration - (Cursor) spelling: IObjContext, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct IObjContext, usr: c:@S@IObjContext
[WARNING]: No definition found for declaration - (Cursor) spelling: DOMDocument, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct DOMDocument, usr: c:@S@DOMDocument
[WARNING]: No definition found for declaration - (Cursor) spelling: DOMFreeThreadedDocument, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct DOMFreeThreadedDocument, usr: c:@S@DOMFreeThreadedDocument
[WARNING]: No definition found for declaration - (Cursor) spelling: XMLHTTPRequest, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct XMLHTTPRequest, usr: c:@S@XMLHTTPRequest
[WARNING]: No definition found for declaration - (Cursor) spelling: XMLDSOControl, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct XMLDSOControl, usr: c:@S@XMLDSOControl
[WARNING]: No definition found for declaration - (Cursor) spelling: XMLDocument, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct XMLDocument, usr: c:@S@XMLDocument
[WARNING]: No definition found for declaration - (Cursor) spelling: _SC_NOTIFICATION_REGISTRATION, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _SC_NOTIFICATION_REGISTRATION, usr: c:@S@_SC_NOTIFICATION_REGISTRATION
[WARNING]: Skipped Function 'IsWindowsVersionOrGreater', inline functions are not supported.
[WARNING]: Skipped Function 'IsWindowsXPOrGreater', inline functions are not supported.
[WARNING]: Skipped Function 'IsWindowsXPSP1OrGreater', inline functions are not supported.
[WARNING]: Skipped Function 'IsWindowsXPSP2OrGreater', inline functions are not supported.
[WARNING]: Skipped Function 'IsWindowsXPSP3OrGreater', inline functions are not supported.
[WARNING]: Skipped Function 'IsWindowsVistaOrGreater', inline functions are not supported.
[WARNING]: Skipped Function 'IsWindowsVistaSP1OrGreater', inline functions are not supported.
[WARNING]: Skipped Function 'IsWindowsVistaSP2OrGreater', inline functions are not supported.
[WARNING]: Skipped Function 'IsWindows7OrGreater', inline functions are not supported.
[WARNING]: Skipped Function 'IsWindows7SP1OrGreater', inline functions are not supported.
[WARNING]: Skipped Function 'IsWindows8OrGreater', inline functions are not supported.
[WARNING]: Skipped Function 'IsWindows8Point1OrGreater', inline functions are not supported.
[WARNING]: Skipped Function 'IsWindowsServer', inline functions are not supported.
[WARNING]: Generated declaration '_OSVERSIONINFOW' starts with '_' and therefore will be private.
Finished, Bindings generated in E:\hybrid_sdk\hybrid_core\hybrid_core_windows\.\lib\src\ffi.g.dar
But inline functions seems not suported.
Correct, inline functions are not supported. For more details see:
For now the workaround is to either make that macro not inline, or wrap the inlined functions in a non-inlined function.
(Background: Inline functions are inlined which means they are not available themselves at runtime, their statements will be inlined on the call site in the C++ code. So you can't FFI-call an inline function because it's code doesn't exist in isolation.)
@dcharkes Thanks, I implemented these inline functions with dart as a temp solution.
Also, Does ffigen support function macros, seems I can only generate the value macros for now?
Also, Does ffigen support function macros, seems I can only generate the value macros for now?
Macros are evaluated by the Clang compiler before it creates its AST, so FFIgen doesn't see the code before macros. (If I am not mistaken. @mannprerak2 would know a more precise answer.)
We've built something special for dealing with constants:
If you have a specific use case of macros, we could consider supporting it.
If you have a specific use case of macros, we could consider supporting it.
Yes, Can these macros supported by ffigen? I have to implement these macros with dart for now.
// minwindef.h
#define MAKEWORD(a, b) ((WORD)(((BYTE)(((DWORD_PTR)(a)) & 0xff)) | ((WORD)((BYTE)(((DWORD_PTR)(b)) & 0xff))) << 8))
#define MAKELONG(a, b) ((LONG)(((WORD)(((DWORD_PTR)(a)) & 0xffff)) | ((DWORD)((WORD)(((DWORD_PTR)(b)) & 0xffff))) << 16))
#define LOWORD(l) ((WORD)(((DWORD_PTR)(l)) & 0xffff))
#define HIWORD(l) ((WORD)((((DWORD_PTR)(l)) >> 16) & 0xffff))
#define LOBYTE(w) ((BYTE)(((DWORD_PTR)(w)) & 0xff))
#define HIBYTE(w) ((BYTE)((((DWORD_PTR)(w)) >> 8) & 0xff))
Okay, let's track that new feature in https://github.com/dart-lang/native/issues/1066.
I tried to generate the Dart bindings of the win32
VersionHelpers.h
with ffigen. The console shows these errors when I run the command.Seems the error is related to the
FORCEINLINE
keyword?