Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: IC problem.[Solved, (feel free to reap)]

by cavac (Parson)
on Jun 12, 2015 at 12:58 UTC ( [id://1130189]=note: print w/replies, xml ) Need Help??


in reply to Re^2: IC problem.[Solved, (feel free to reap)]
in thread IC problem.[Solved, (feel free to reap)]

Hmm, interesting. I also would have thought that in a union-type, all variables start at offset zero.

I thought i have seen it used something like this (pseudo-code, my C coding days are mostly over so i'm not really sure how this is all supposed to look): Image you want to have different IP records in memory, say,

typedef struct { uint32 type; char ip[4]; } ipv4; typedef struct { uint32 type; char ip[16]; } ipv6;
Then you would be able to have an union type of both and access the first field ("type") to cast the variable to the the correct typedef?

As said, my C coding days are mostly over. But since i have some XS work coming up, i might as well start to think about such problems right now :-)

"For me, programming in Perl is like my cooking. The result may not always taste nice, but it's quick, painless and it get's food on the table."

Replies are listed 'Best First'.
Re^4: IC problem.[Solved, (feel free to reap)]
by BrowserUk (Patriarch) on Jun 12, 2015 at 14:04 UTC
    in a union-type, all variables start at offset zero.

    They do. But the bit fields are in a struct nested inside the union. The problem I describe is unique to bit-fields; and unique to bit-fields on 64-bit.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

      Thanks for the clarification.

      "For me, programming in Perl is like my cooking. The result may not always taste nice, but it's quick, painless and it get's food on the table."

        I should add; the problem as I experienced it may also be unique to MSVC.

        It's one of those areas of the C-language where the various specifications leave much of the implementation details up to the compiler writers.

        I have no idea whether the same problem applies to gcc or others.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
        In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1130189]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found