Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/21/06 21:37
Read: times


 
#118810 - well...
Responding to: ???'s previous message
Andy Peters said:
Dunno why the function declaration is externed.

True, it is not necessary to specify 'extern', but there is nothing wrong nor even particularly unusual about it.

It makes some sort of sense to put 'extern' to emphasise that the actual definition (or "implementaion") is external to this compilation unit.

It should be declared in a header file that's included by the C source, and not externed.

Whether you put the declaration in a header file or the 'C' source file is merely a matter of style; it makes no difference whatsoever to the compiler. In either place, the 'extern' keyword is perfectly permissible - see above.

Anyways: your code calls a function lcdinit(). The extern modifier says that "somewhere a function called lcdinit() has a definition."

Exactly.

However, that definition isn't available.

Hence the Linker complains that it is "Undefined"; ie, literally, there is no definition.

You need a source file that has the implementation of lcdinit()

Not necessarily a Source file - a suitable object file or Library would be fine.

and a header file that declares lcdinit()'s interface

Again, it is not necessary to use a header file; it is certainly conventional, and often advisable, but not strictly essential.


List of 18 messages in thread
TopicAuthorDate
Hi-tech C compile problem            01/01/70 00:00      
   Linker            01/01/70 00:00      
   Less Detail            01/01/70 00:00      
      'C' Globals            01/01/70 00:00      
   extern-ing a function declaration?            01/01/70 00:00      
      well...            01/01/70 00:00      
         The Secret            01/01/70 00:00      
            case was not an issue            01/01/70 00:00      
            Case still not an issue            01/01/70 00:00      
               Incorrect deduction            01/01/70 00:00      
                  Maybe Not            01/01/70 00:00      
                     Linker            01/01/70 00:00      
                        make            01/01/70 00:00      
   use Win98SE in a virtual machine, QEMU?            01/01/70 00:00      
      Vmware            01/01/70 00:00      
   Just a guess            01/01/70 00:00      
      possibly, but            01/01/70 00:00      
         after all the 'logicl' possibilities hav            01/01/70 00:00      

Back to Subject List