Giter VIP home page Giter VIP logo

Comments (4)

jacobly0 avatar jacobly0 commented on May 29, 2024 4

and have packed struct(u8) and packed union(u8)

Actually, thinking about it some more, this should definitely be a requirement for many different reasons. The most obvious is that an 8-bit packed union should be allowed in callconv(.C) function parameters, but the C abi of u8 and i8 differ, so the user needs to specify which one to use!

from zig.

expikr avatar expikr commented on May 29, 2024 1

Can multiple unused fields use _ as their field name provided that they have a default initialization value?

from zig.

Rexicon226 avatar Rexicon226 commented on May 29, 2024

A small change I propose is to instead of requiring them to have the same @bitSizeOf, which could lead to some weird behaviour and error messages like in cases such as:

const U = packed union {
    a: u7,
    b: u8, 
    c: u8,
    d: u9,
}

What would the error here be? Either

  1. it would resolve to being u8 as the majority, and u7 and u9 are wrong
  2. it'll coerce to the largest size which might not be desired

Instead I think it makes more sense to unify the current semantics, and have packed struct(u8) and packed union(u8), and the "same @bitSizeOf" must match the provided backing int.

from zig.

mochalins avatar mochalins commented on May 29, 2024

#19395 seems relevant here

from zig.

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.