Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Rockbox Ports are now being developed for various digital audio players!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  uninitialized elements
« previous next »
  • Print
Pages: [1]

Author Topic: uninitialized elements  (Read 1624 times)

Offline mschneider

  • Member
  • *
  • Posts: 235
uninitialized elements
« on: June 18, 2008, 10:59:29 PM »
I've made a pointer to a structure like this:

Code: [Select]
struct mystructure *p

I access the structure various times but when I compile I get a warning that says "p" (I'm assuming that means the entire structure) is uninitialized in the function. What exactly does this mean?
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: uninitialized elements
« Reply #1 on: June 19, 2008, 12:22:58 AM »
Usually that means you're trying to dereference a pointer you haven't set to anything.  Have you actually assigned p a value before you try to use it?  On device, unlike on a PC, you can often dereference things that aren't actually valid pointers without crashing since theres no MMU watching what you're doing.
Logged

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: uninitialized elements
« Reply #2 on: June 19, 2008, 12:50:43 PM »
(Sorry, I'm horrible with pointers and I'm a little rusty on my coding), I did not think that a pointer to a structure needed a value. I thought you merely declared it as a pointer and then used it to pass things off to the structure. How would I set it to a value?
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: uninitialized elements
« Reply #3 on: June 19, 2008, 01:10:01 PM »
well, as a pointer to a structure is still a pointer so it needs something to point to -- in that case it needs to point to a variable of that structure. Of course the pointer is initialized even if it points to some nonsense location or is set to NULL. You shouldn't forget to check against a NULL pointer before using it (in a function) of course.

You can understand it as a pointer doesn't have a value but a location it points to. If you haven't set the location its uninitialized.
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: uninitialized elements
« Reply #4 on: June 19, 2008, 01:27:08 PM »
Ok, that makes sense. thank you.
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  uninitialized elements
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.073 seconds with 15 queries.