Giter Club home page Giter Club logo

Comments (3)

phronmophobic avatar phronmophobic commented on May 24, 2024

I'm also getting a mismatch for the following struct:

typedef struct S2 {
    int i;
    void *data[2];
} S2;

int main(int n, char** args){
    printf("size: %lu\n", sizeof(S2));
}

This prints 24, but coffi/size-of reports 20.

(defalias ::S2
  (layout/with-c-layout
   [::mem/struct
    [[:i ::mem/int]
     [:data [:coffi.mem/array [:coffi.mem/pointer :coffi.mem/void] 2]]]]))

(mem/size-of ::S2) ;; 20

from coffi.

IGJoshua avatar IGJoshua commented on May 24, 2024

Ah, yeah, this was an issue I observed before that I've determined a fix for but it appears I applied it inconsistently. All the value layouts in the JVM-side default to an alignment of 1, which is incorrect, and I corrected this for primitive numbers, but it appears I forgot to do the same for pointers. I believe that the array in your second example should be fixed if I fix the alignment of pointers, but I'll check up on that as well.

from coffi.

IGJoshua avatar IGJoshua commented on May 24, 2024

This is now fixed on the latest develop. I'll be working on a release soon which will include it.

from coffi.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.