Skip to content

ownSizeOf macro gives me negative sizes #133

@janflyborg

Description

@janflyborg

Have been wrapping libfuse succesfully with Futhark and I find it excellent. To make it work for 32-bit targets, I had to override two types before importing the generated code:

# These overrides are needed for this to work on 32-bit platforms
struct_stat* = posix.Stat
off_t* = posix.Off
include "libfuse_generated.nim"

Everything works as it should, however, it gave me a warning I couldn't get rid of:

libfuse_generated.nim(908, 16) Warning: Declaration of off_t exists but with different size [User]

When further investigating this, it is the following guard that gives me this:

when ownSizeof(off_t) != ownSizeof(off_t_536871605):
  static :
    warning("Declaration of " & "off_t" & " exists but with different size")

But the strange thing is that ownSizeof(off_t_536871605) gives me the value -3 (when I print it out with a hint), so this comparison will always fail, so something seems to be wrong with ownSizeof for some arguments. I have now changed it into the following definition and the warning is gone:

macro ownSizeof(x: typed): int =
  newLit(typeof(x).sizeof)

I can of course override it before including the generated code, but is this maybe something that should be changed in the code generator?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions