Thread: Static Local Variable vs. Global Variable

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Be kind to yourself. Otherwise we are all doofus sometimes. More times than any of us would outrightedly admit to.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I agree with master - I had to have my colleague point out to me that "addressing the last byte in this memory is not number X but X-1" yesterday. I should know that!

    And the reason it changed when you made it static instead of global is probably just the ordering of variables in the data segment. Previously, you'd overwrite something that didn't make it crash!

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with Free.
    By chakra in forum C Programming
    Replies: 9
    Last Post: 12-15-2008, 11:20 AM
  2. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 01:22 PM
  3. global and static variable in a class delivered in a DLL
    By George2 in forum C++ Programming
    Replies: 16
    Last Post: 04-13-2008, 08:19 AM
  4. [GLUT] Pointers to class methods
    By cboard_member in forum C++ Programming
    Replies: 13
    Last Post: 02-16-2006, 04:03 PM
  5. global variable and header question
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 08-05-2002, 11:38 PM