Author Topic: Atmel Studio compiler errors  (Read 9487 times)

0 Members and 1 Guest are viewing this topic.

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Atmel Studio compiler errors
« on: August 29, 2014, 07:03:08 pm »
What does this warning mean ?

Warning   2   control reaches end of non-void function [-Wreturn-type]   

It relates to this code:

Code: [Select]
TIMER0_COMPA_vect()
{
count++;
}

The count variable has been declared as a volatile variable.

I am also getting other complaints around the watchdog timer reset code but I can't work out why as I'm just using the wdt_reset    (       ); that is specified in the manual but errors have been asking me for "(" in front of parts of code in the library file that is none of my business. This was after commenting some of the code out and then trying to put it back. Basically the compiler is unstable at best.
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline andersm

  • Frequent Contributor
  • **
  • Posts: 992
  • Country: fi
Re: Atmel Studio compiler errors
« Reply #1 on: August 29, 2014, 07:46:25 pm »
The warning means that there is a function that is declared to return a value (eg. int foo(...)), but there is an execution path that reaches the end of the function without returning a value. I doubt it is related to the code you showed.

I don't mean this as an insult, but you have a history of making lots of beginner's errors. Before blaming the compiler, make sure you have all your i's dotted and t's crossed.

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Atmel Studio compiler errors
« Reply #2 on: August 29, 2014, 08:03:32 pm »
According to responses i got on avr freaks i should have used ISR(TIMER0_COMPA_vect) So that one is sorted.

The code previously worked, I commented some of it out and then removed the comments and now I get errors relating to code in the watchdog header file which is out of my control, I think that's unusual is it not ? I also experience instances where first the code refuses to compile and on a second attempt it does, I think that constitutes unstable.
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Atmel Studio compiler errors
« Reply #3 on: August 29, 2014, 08:39:57 pm »
Using my original code works again, but still it took two attempts to compile and things that compiled correctly on one computer don't compile on another despite having the same versions. it also seems to make a difference as to where my cursor is when i hit build which i don't understand.
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 12765
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Atmel Studio compiler errors
« Reply #4 on: August 29, 2014, 11:58:35 pm »
To guarantee consistent builds, you should probably wipe output data every once in a while.  C compilers are not inconsistent (they're deterministic programs), but they are stateful, in that if you have compiled modules that weren't changed (or so it seems), it will include them without recompiling.  Which can lead to inconsistent results, perhaps if some header files changed or something.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Atmel Studio compiler errors
« Reply #5 on: August 30, 2014, 12:23:55 am »
ah that is interesting, and how do i clear "output data" ?
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 12765
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Atmel Studio compiler errors
« Reply #6 on: August 30, 2014, 12:45:51 am »
Project / Clean Project, or something like that.  I forget where Atmel/AVR Studio has that at.  Or you go into the output directory and delete it yourself.
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Atmel Studio compiler errors
« Reply #7 on: August 30, 2014, 03:16:57 am »
hm, pretty roundabout when your making minor code changes and want to keep verifying them.
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline sporadic

  • Regular Contributor
  • *
  • Posts: 69
  • Country: us
    • forkineye.com
Re: Atmel Studio compiler errors
« Reply #8 on: August 30, 2014, 03:55:54 am »
In regards to error references within a system header file, that's usually caused by a macro expansion gone bad or malformed code block in the users code.  The cleaning referred to above will cleanup all the intermediate compiled objects and what not required to create your final binary.  Very much like a "make clean".  An object won't re-compile unless it needs to (source changed or compiled object removed), so if you see a warning the first time around in say "mystuff.c", make a change in "main.c", and recompile, you won't see the warning from mystuff.c again until you do a "make clean", or in Atmel Studio's case, "Build->Clean Solution".  Have a link for the thread you have going on avrfreaks?
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Atmel Studio compiler errors
« Reply #9 on: August 30, 2014, 04:31:11 am »
So basically i need to do a clean build each time to make sure ?
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline sporadic

  • Regular Contributor
  • *
  • Posts: 69
  • Country: us
    • forkineye.com
Re: Atmel Studio compiler errors
« Reply #10 on: August 30, 2014, 05:24:29 am »
So basically i need to do a clean build each time to make sure ?
If you're wanting to re-compile all files each time and see the warnings for them again, yes.  Atmel Studio's default build configuration turns on many of GCC's warning flags so it can be pretty verbose at times.  Many warnings are just that and won't cause runtime issues, but its best to deal with them if you can.  So generally, you don't need to do a clean build unless you want to go back and check your warnings for all modules or you've been prodding around doing something that messed up the make system / causing the linker to fail.  I rarely have to do a clean, but its good for a sanity check every now and then.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Atmel Studio compiler errors
« Reply #11 on: August 30, 2014, 05:52:31 pm »
Yea apparently now I have variables that are not being modified when they clearly are..........
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline andersm

  • Frequent Contributor
  • **
  • Posts: 992
  • Country: fi
Re: Atmel Studio compiler errors
« Reply #12 on: August 30, 2014, 07:00:20 pm »
Yea apparently now I have variables that are not being modified when they clearly are..........
Please post an example.

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2599
  • Country: au
Re: Atmel Studio compiler errors
« Reply #13 on: August 30, 2014, 07:01:40 pm »
Without seeing the whole project it's hard to tell, but maybe the variables are not correctly defined?  I've had no issues with variables marked as volatile.

Maybe check for other silly mistakes such as calling a function without the parenthesis.  Things like this can really screw things up without generating errors.

So far, each time I've seen something weird going on it's been a typo or me not completely understanding C.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Atmel Studio compiler errors
« Reply #14 on: August 30, 2014, 07:56:48 pm »
Well I'll continue probing monday and be able to post some code

https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: gb
Re: Atmel Studio compiler errors
« Reply #15 on: September 01, 2014, 03:49:58 am »
Just bear in mind that weird compilation errors are 99.999% caused by user code.  Missing brackets etc. can cause errors to be shown in apparently unrelated code, but with experience you get a feeling for where the real problem is likely to be.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Atmel Studio compiler errors
« Reply #16 on: September 01, 2014, 03:53:59 am »
It's just weird that first it fails and then it succeeds with no code change, I need to look at the second computer i am using as most problems occur moving to that.

As pointed out previously a clean built is the best option to clear any old bits of code the compiler is hanging onto that I may have changed anyway.

I have

watchgod reset code

while(1)

watchdog reset code

and I'm getting error in the watchdog header file........

Reverting to a previous copy of the program fixes it all.
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7805
  • Country: us
  • adieu
Re: Atmel Studio compiler errors
« Reply #17 on: September 01, 2014, 04:02:22 am »
watchgod reset code

while(1)

watchdog reset code

It'd be seriously helpful if your pseudocode was, well, pseudo-code. With structures and all that. Is the third line inside the while(1), or have you tried to make the processor halt at the while(1)? That could make a difference.

Quote
and I'm getting error in the watchdog header file........

Remember that the compiler lumps all the headers together at the beginning of your file. Errors in a header that ought to be okay are often actually latent errors from things before the header's #include line. What did you do before #include <avr/wdt.h> ?

Quote
Reverting to a previous copy of the program fixes it all.

Usually a sign that you changed something and broke it, not a sign that the compiler's "unstable". ::) Would you be so kind as to share a minimal diff?
« Last Edit: September 01, 2014, 04:04:49 am by c4757p »
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Atmel Studio compiler errors
« Reply #18 on: September 01, 2014, 04:05:35 am »
Sorry to be cleare it was and i forgot a parenthesis:

Code: [Select]

main()
{
watchgod reset code

while(1)
{

watchdog reset code

rest of code in loop
}
}
[code/]

The 3 errors I got pointed to before and after the while in my code but stated that there needed to be "(" in some code, the code it referred to is in the watchdog header file.
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: Atmel Studio compiler errors
« Reply #19 on: September 01, 2014, 04:16:22 am »
It actually will be helpful to put the actual code snippets if you are getting compiler errors.


 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Atmel Studio compiler errors
« Reply #20 on: September 01, 2014, 04:20:07 am »
I'll post some tomorrow
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Atmel Studio compiler errors
« Reply #21 on: September 01, 2014, 04:22:18 am »
I'll do that tomorrow although I've gone back to my original and in any case identical copy and got no errors, hence my comments about instability, these may be down to not doing a clean build.
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline true

  • Frequent Contributor
  • **
  • Posts: 296
  • Country: us
  • INTERNET
Re: Atmel Studio compiler errors
« Reply #22 on: September 01, 2014, 05:16:59 am »
No, it very likely isn't.

I'll wait for code.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 12906
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Atmel Studio compiler errors
« Reply #23 on: September 01, 2014, 05:18:20 am »
Well then as far as i can tell i have 2 pieces of code that say the same thing but only one works.
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2599
  • Country: au
Re: Atmel Studio compiler errors
« Reply #24 on: September 01, 2014, 07:55:05 am »
My money is on them not being the same.  About the only other thing I can think of is the file has gotten mangled with bad CR/LF ?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf