GithubHelp home page GithubHelp logo

Comments (14)

deech avatar deech commented on June 10, 2024 1

I started a small repo to capture and run alignment and sizeof test cases, feel free to fork it and add more. Once the feature is complete we can port them back to this repo.

from c2hs.

deech avatar deech commented on June 10, 2024

This is happening because currently c2hs ignores all aligned (and packed) GNU specific attributes. In this particular case 1 is accidentally correct because 384 is a multiple of 64 and so the field will naturally align at a 64 bit boundary. I'm not sure when I'll have time to add support for them.

from c2hs.

Kleidukos avatar Kleidukos commented on June 10, 2024

@deech If you have an idea of how to do it maybe I can take a shot at it?

from c2hs.

deech avatar deech commented on June 10, 2024

Yes absolutely, the addition would start where we calculate struct and struct field alignments and sizes and affect calculations downstream of that. The GNU specific packed and aligned attributes are passed along in a CAttr, you can read more about them in the GCC manual. I can even walk you through the code that currently exists if you like. Brace yourself, this is a relatively involved change. 😄

The other option is we simply don't support alignment attributes in c2hs and actually error in their presence although I would suspect this would break a bunch of code in the wild.

from c2hs.

deech avatar deech commented on June 10, 2024

Yet another option is to generate a C file that includes the header and print the values we need using the builtin sizeof, alignof and offsetof. We do this currently to get the size of a bool. Honestly if we can reliably generate the file this might be the best approach.

from c2hs.

deech avatar deech commented on June 10, 2024

@Kleidukos Are you still interested in working on this issue? I'm happy to help you with it.

from c2hs.

Kleidukos avatar Kleidukos commented on June 10, 2024

@deech I would love some help on that one. :)

from c2hs.

deech avatar deech commented on June 10, 2024

Cool! Send an email to the last maintainer address listed on the Hackage page and we can set up a time to jump on a call and we can talk through options.

from c2hs.

Kleidukos avatar Kleidukos commented on June 10, 2024

@kozross ☝️

from c2hs.

deech avatar deech commented on June 10, 2024

Bump

from c2hs.

kozross avatar kozross commented on June 10, 2024

@deech @Kleidukos and I are looking at the example and working out a way forward: thanks for that!

from c2hs.

deech avatar deech commented on June 10, 2024

@Kleidukos @kozross Are you still planning on working this issue? Is there anything I can do to help?

from c2hs.

Kleidukos avatar Kleidukos commented on June 10, 2024

@deech We had to pause a bit this last month but I'd like to work on it again. :) We'll ping you it ever is blocked by something big. In the meantime if someone submits a PR with a fix, don't wait for us!

from c2hs.

Kleidukos avatar Kleidukos commented on June 10, 2024

@deech Coming back to say that it is going to be quite hard for me to bring this to completion. If you ever feel like fixing it, do feel free. :) Thank you for your support in any case!

from c2hs.

Related Issues (20)

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.