Thread: Structures as members of structures & offset

  1. #16
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    My second point explains why you won't normally see this code. My third point, was why it might be interesting to examine. OS developers are allowed to make assumptions about their architecture and use non standard code. Additionally, the creaters of compilers can, and sometime do, have non standard things going on under the hood because they can guarantee the outcome of the code.

    So in these implementations the outcome is very much so guaranteed, by the assumptions made by the designers.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  2. #17
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by AndrewHunter View Post
    My third point, was why it might be interesting to examine. OS developers are allowed to make assumptions about their architecture and use non standard code.
    I understand why you wanted to explain what was likely to happen.
    Quote Originally Posted by AndrewHunter View Post
    Additionally, the creaters of compilers can, and sometime do, have non standard things going on under the hood because they can guarantee the outcome of the code.

    So in these implementations the outcome is very much so guaranteed, by the assumptions made by the designers.
    They can guarantee it, but I don't have to. You can't guarantee it. C doesn't guarantee it. Some random guy for some random OS on some random hardware guarantees it. It doesn't make his guarantee mean any more than mine. It's undefined by the language. If I say "It seg faults because you just dereferenced a null pointer", I'm right to say so. If he says "No it doesnt, it's for my specific hardware that won't seg fault!". If anything, I'm still more right than he is, if I'm quoting the C standard correctly.

    You said it yourself, it is undefnied. If it's undefined, then no, you can't say "This is guaranteed to happen!" Not in reference to the standard anyway. In reference to Bob the random hardware guy you can, but you aren't citing him as a reference point, and so you can't qualify your statement and have it mean anything more than me citing the standard saying you are wrong.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #18
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    I think we both agree that this code is not standard. All I am saying is that the OP could see something like this in the future and there is a point to understanding what the code did. As for OS developers, they can and do create non standard code for use within there OS because they can guarantee the outcome of that code(the *nix thing I talked about), which works on many peoples computers. As for the compiler developers I was referring that they could guarantee how their code would work during the compilation phase. the Offsetof() macro use to use this type of coding. It was however a macro that would eventually get converted into a jmp table during compilation phase and thus not cause a segfault on anyone's system. They did guarantee that it would make the conversion.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  4. #19
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    Why on earth would I ever do what they are doing?
    "Because it's there..."

    What's that? Sir Edmond Hillory and Lorena Bobbet... Right...

    Never mind.

  5. #20
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by CommonTater View Post
    Lorena Bobbet... Right...
    That comment was below the belt.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #21
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    That comment was below the belt.
    But hardly a solo act ... Torture charge after penis put in garbage disposal - World - CBC News

  7. #22
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by CommonTater View Post
    But hardly a solo act ...
    I'm going to get snippy if you don't cut that out.


    Quzah.
    Hope is the first step on the road to disappointment.

  8. #23
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    I'm going to get snippy if you don't cut that out.
    Your razor sharp whit cuts me to the quick, my friend...

  9. #24
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    This thread has come up a bit short in the pun department.


    Quzah.
    Hope is the first step on the road to disappointment.

  10. #25
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    This thread has come up a bit short in the pun department.
    Quzah.
    What? You expected Shakespeare's pound of flesh?

    (Yes, that's really what they were talking about.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. structures and pointers and members
    By Striker87 in forum C Programming
    Replies: 3
    Last Post: 04-18-2011, 10:54 PM
  2. passing static structures members to function
    By bhagwat_maimt in forum C++ Programming
    Replies: 0
    Last Post: 11-17-2006, 04:13 AM
  3. Changing a Structures Members array size
    By Xei in forum C++ Programming
    Replies: 1
    Last Post: 11-07-2002, 07:45 PM
  4. Help with pointers and members of structures
    By klawton in forum C Programming
    Replies: 2
    Last Post: 04-19-2002, 12:34 PM
  5. Accessing members of structures
    By Nutshell in forum C Programming
    Replies: 6
    Last Post: 02-03-2002, 12:10 PM