NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » warning: initialization makes integer from pointer...
January 10, 2013 by keith712 |
i'm slowly learning c and i've run into something interresting that i don't understand. my compiler gives the following warning:
for every line like:
in all the functions in my program (including main()) i also get this warning:
for the line:
pin_value is the variable being returned from a function to main() the interresting thing is that if i recompile the program after making a change all the warnings disappear!!! what gives? |
---|---|
January 10, 2013 by pcbolt |
keith - Try
And
I'm guessing you have an "if" statement in your function that may or may not assign 'pin_value' to some value. The compiler should assign 'pin_value' to 0 if you don't assign it to anything when you declare it. But if for some wild reason it did not, you wouldn't be certain what got returned from your function. |
January 10, 2013 by keith712 |
thanks as always... all the warnings disappeared when i made the changes you suggested... you're exactly right: pin_value is assigned a value in an if-else if-else block... and because i'm a refugee from Python i didn't even think there might be a difference between "B" and 'B'... a little knowledge can be dangerous... keith |
Please log in to post a reply.
Did you know that LEDs (light emitting diodes) only conduct current in one direction, like normal diodes? Learn more...
|