warning: "Implicit declaration..."[Solved]

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For my xmega16A4 FatFS mp3 player I get that warning for my spiC_wrt() in my main.c file.

In main.c:

init_media(); // warning here

In vs1011.c : init_media() -> sd_cmd() -> spiC_wrt()

Since I include vs1011.h in main.c, why would it give this warning? Why doesn't it know about that function via header file just like it knows about init_media() ? I know that putting a func. declaration or extern would fix it though.

thanks in advance

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

Last Edited: Sat. Dec 4, 2010 - 02:43 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
why would it give this warning?
Because you did not include the actual C file that contains the code in your project?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did, using tools #2 & #3 in sign.

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So when you click on the source files window you can see the file that contains the code?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
extern void init_media(void); // declared in C or H file

   ...
   init_media(); // no warnings now
   ...

The Compiler must have already been told the 'signature' of any function before it is used.

It is common to put all the function prototypes that are defined in "module.c" in a header called "module.h".
Note that the 'extern' keyword is optional.
A function that takes no parameters should use the void keyword e.g. function(void). A function that does not return a value should be declared as a void function().

If you omit the function return type, it defaults to int.

If you omit the parameters in a prototype the Compiler cannot check your usage.

C files will compile just fine with the correct declarations.
The Linker will complain if it cannot resolve all the externals. e.g. you forget the C file that defines init_media()

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

John: Yes
David, that's my point I've done all that so it was a surprise to see the warning. If I do the extern like U, I get the same warning.

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is it spelled correctly? Maybe the declaration and definition are spelled differently.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Correctly spelled.

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What function does not it like, spiC_wrt or init_media? Is init_media a macro? Your OP does not make much sense.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Doesn't like spiC_wrt(). Init_media()'s called from main.c and init_media() and spiC_wrt() are defined in vs1011.c. Arrows meant that init. calls functions pointed to.

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The exact error message would be nice...
Does it complain about main.c or vs1011.c? I guess about vs1011.c. In vs1011.c, do you define spiC_wrt before you call it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I found it ! In vs1011.h file I had declared it as spi_wrt(). :oops: I must have made the change months ago, 'cause i know it was in there at 1st. I remember now taking out the 'C' just to min. the function name, but then I thought since the xmega has multiple spi that it would be better to qualify each by its port letter ( and forgot to change it back in *.h ). Since the code worked, I just moved on to other things and only now dived back into it to see about getting rid of warning. I'm Sorry to waste your time.

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1