Like Tree2Likes

Memory allocated to variables of a function on different function calls

This is a discussion on Memory allocated to variables of a function on different function calls within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by tabstop "Generated machine code" might be a little bit of a stretch, but presumably if you knew ...

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Quote Originally Posted by tabstop View Post
    "Generated machine code" might be a little bit of a stretch, but presumably if you knew all the opcodes for the chip, and the binary format, etc, then you could "read" an exe file. I don't know anyone who's ever even tried this, and wouldn't expect anyone to actually do so.

    But you can get some idea by having your compiler stop at generating the assembly code, which has got pretty much all the gory details while still at least pretending to be readable. How you do that depends on your compiler. (You can find some information about assembly language on the net; the last time I looked I didn't find anything extremely up-to-date (because people just aren't writing assembly that much any more), but for programs such as the one you've got it will be good enough.)
    Well, to be honest, I've found myself looking at the assembly of generated C++ code from time to time to find out what the heck is happening.
    But to disassemble an entire executable file is probably not very many people who do.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User capt.jack's Avatar
    Join Date
    Jun 2010
    Posts
    13
    Quote Originally Posted by tabstop View Post
    "Generated machine code" might be a little bit of a stretch, but presumably if you knew all the opcodes for the chip, and the binary format, etc, then you could "read" an exe file......
    That seems way too complicated for the moment, I think I'll keep this experimentation reserved for future
    anyway thanx for the tip
    Last edited by capt.jack; 09-06-2011 at 01:21 PM.

  3. #18
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,302
    Quote Originally Posted by capt.jack View Post
    I strongly disagree with your "No Trespassing" theory where one should force himself into categorizing down any statement on programming behaviour into either some theoretical "one-should-not-care-to-test" statement or a statement (according to you) having some worthy "testable behavior"; because if I would'nt have tested that statement and initiated a discussion here then I might not have(if not later) learnt the "inferred conclusion" in the post above.
    OR can you please go ahead and kindly define the parameters you use to judge a statement's worth to be tested or not
    It's not about worth. Is a no trespassing sign worth testing? It simply doesn't make sense. You made assumptions about the statement such as thinking that variables could not occupy the same space in memory they did last time. Whether they do or not has no bearing on the assumptions the author is asking you to make or not make.

    That wasn't a theory I mentioned, it was a metaphor for the particular statement in question. By no means do I intend the same logic to apply to things willy-nilly. Really the original statement being discussed comes down to the author saying "assume nothing". Now you can make assumptions and then test those assumptions, but as I think you've now come to realise, that doesn't and in fact cant invalidate what the original statement says. Just assume no knowledge of the location of your variables is the intent the author is trying to get across here.

    Revered Sir,
    proving that might be an utter foolishness and worthless for you but for a humble beginner like me, the learning from the proof is worth its salt
    You simply misunderstood. It's not about not being worthy of proving, it makes no sense to try and prove, just like the no trespassing sign example, because it is not a statement about the behaviour that your compiled program will actually give.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #19
    Registered User capt.jack's Avatar
    Join Date
    Jun 2010
    Posts
    13
    Quote Originally Posted by iMalc View Post
    Really the original statement being discussed comes down to the author saying "assume nothing". Now you can make assumptions and then test those assumptions, but as I think you've now come to realise, that doesn't and in fact cant invalidate what the original statement says. Just assume no knowledge of the location of your variables is the intent the author is trying to get across here.......
    the question is not whether I misunderstood you or not, whether you mentioned "No Trespassing" as a metaphor or as a theory but rather the question is "How in the world would I know whether the assumptions made by me are true or a big fat fallacy" ? or whether I'm "not allowed" to make any assumptions at all ?
    Unless I experiment and post my doubts here, how can I learn that the statement at hand is the "world's-most-obvious-fact" ?


    It's not about not being worthy of proving, it makes no sense to try and prove, just like the no trespassing sign example, because it is not a statement about the behaviour that your compiled program will actually give
    you being an experienced C++ expert, is in a position to make that call but for beginners like me experimenting and then asking the experts is the right way to proceed on the learning curve, in fact even to make the "obvious" distinction of whether the statement is about the behaviour that your compiled program will give or not, I have to experiment, thats the way I am because for me experimentation is the road to salvation

    Just assume no knowledge of the location of your variables is the intent the author is trying to get across here.
    I respectfully refuse to take things "granted" and I am determined to experiment and post as many foolish questions as I can, even though it may make me the laughing stock of the forum or bag me many funny jibes(or even "NoTrespassing" metaphors) or whatever, but I don't care until I am learning


    Stay Hungry, Stay Foolish

  5. #20
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Experimentation is good. But there are simply some things that you cannot get a proper understanding from through experimentation alone. Memory management like this is one of them, because it will be different from platform to platform and various circumstances.
    If you want to know more, then you shouldn't experiment, but instead study operating system principles and see how they would deal with it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 01-15-2011, 12:47 PM
  2. Replies: 2
    Last Post: 06-25-2010, 04:04 AM
  3. template variables in function calls
    By DoMeN in forum C++ Programming
    Replies: 1
    Last Post: 02-11-2008, 05:11 AM
  4. arg...function calls
    By 2fastwrx in forum C++ Programming
    Replies: 8
    Last Post: 09-23-2004, 10:55 PM
  5. function calls
    By Draco in forum C Programming
    Replies: 3
    Last Post: 11-09-2003, 03:28 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21