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

Back to Subject List

Thread Closed: Issue successfully resolved

???
02/01/05 19:00
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#86306 - Completely wrong!
Responding to: ???'s previous message
The 'extern' declarations should go in the header;
The actual definitions (with initialisations) should go in the 'C' file.

header.h
// Note that the array sizes are not needed here
extern code unsigned int x_data[]; 
extern code unsigned int y_data[];

mainfile.c
#include <headerfile.h> // This is included here so that the compiler can warn
                        // if the 'extern' declarations don't match the actual definitions!

code unsigned int x_data[10]={0,1,2,3,4,5,6,7,8,9};
code unsigned int y_data[10]={10,11,12,13,14,15,16,17,18,19};
etc

otherfile.c
#include <headerfile.h> // This gives access to the 'extern' declarations


If you had the definitions in the header, as you originally showed, you would get Linker errors complaining about Multiple Definitions

List of 5 messages in thread
TopicAuthorDate
lookup table and extern            01/01/70 00:00      
   Completely wrong!            01/01/70 00:00      
      OK            01/01/70 00:00      
   The struct            01/01/70 00:00      
      Thanks            01/01/70 00:00      

Back to Subject List