-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
The automatic macro extractor...
module TestCBindingDefine
using CBinding
let
opts = [""]
c`$(opts)`
end
c"""
#define MyVal 1e3
"""ji
end
fails in this case because 1e3 matches both the int
and float
checks in this function
Error
WARNING: replacing module TestCBindingDefine.
ERROR: LoadError: ArgumentError: invalid base 10 digit 'e' in "1e3"
Cause
function getexprs_macro(ctx::Context{:c}, cursor::CXCursor)
exprs = []
expr = Bool(clang_Cursor_isMacroFunctionLike(cursor)) ? nothing : ""
for (ind, token) in enumerate(tokenize(ctx.tu[], cursor))
ind == 1 && continue # first token is the macro name itself, so skip it
expr === nothing && break
str = string(ctx.tu[], token)
kind = clang_getTokenKind(token)
if kind == CXToken_Literal
int = match(r"^(0|0x|0b)?([\da-f]+)([ul]*)$", lowercase(str))
float = match(r"^(\d*\.)?(\d*)(e[-+]?\d+)?([fl])?$", lowercase(str))
...
A related line occurs in the Qhull include files... so here's the real-world scenario.
module QhullAuto
using CBinding
using Qhull_jll
#c`-I/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/ -I$(joinpath(Qhull_jll.artifact_dir, "include", "libqhull_r"))`
let
opts = ["-I/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/",
"-I$(joinpath(Qhull_jll.artifact_dir, "include", "libqhull_r"))",
"-L$(dirname(Qhull_jll.libqhull_r))",
"-l$(splitpath(Qhull_jll.libqhull_r)[end])"]
c`$(opts)`
end
c"""
#include "qhull_ra.h"
"""ji
end
Metadata
Metadata
Assignees
Labels
No labels