Thread: globals
this noob question, oh well.
i've read somewhere globals best defined on stack. that's nice , all, how when have large resources (image files, etc.) you'd rather global parts of program , can't defined on stack? can define pointer on stack in 1 file have others have extern in other files, yes, actual data on heap.
how problem? unless sloppy?
know send address of said resources each , every function in other files uses them, , conscious you're sending who, makes things more cumbersome, having make long arrays of pointers resources, example, when defining them global, , being careful, do.
thanks.
you're given relatively small amount of memory on stack work with, whereas amount of heap space you're allowed request scales amount of available memory. thus, big things go on heap, , small local things go on stack.
you run risk of corrupting stack. taking random global may or may not know size of , manipulating asking buffer overflow. it's not big of deal on small projects 1 person doing of coding, , know details of implementation.how problem? unless sloppy?
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk globals
Ubuntu
Comments
Post a Comment