futhark
futhark copied to clipboard
libclang on Windows sometimes outputs paths with `/` as path separators instead of `\`
It's not really an issue in Futhark, but it affects Futhark and I figured it'd be worth reporting it to maybe add a workaround or at least let others know.
Let's add a debug echo to the getLocation
procedure:
proc getLocation(c: CXCursor): tuple[filename: string, line, column: cuint] =
var filename: CXString
c.getCursorLocation.getPresumedLocation(filename.addr, result.line.addr, result.column.addr)
result.filename = $filename
echo result.filename
For some reason on Windows result.filename
might have / for a part (!) of the path:
A possible workaround is to add:
# Workaround issue #37
when defined(windows):
result.filename = result.filename.replace('/', '\\')
to the end of getLocation
and replace fname
with:
when not defined(windows):
let fname = $file.getFileName
else:
let fname = ($file.getFileName).replace('/', '\\')
in genMacroDecl
. It should be generally safe because /
is not a valid character for a filename in Windows anyway