Link error in CodeWarrior for a HC08 device

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Link error in CodeWarrior for a HC08 device

1,571 次查看
IvanWagner
Contributor I
Hi to everyone,
 
I'm trying to compile some sort of software using CodeWarrior for a HC08 device but I'm having problems with the Linker. In fact I have this header file in which there's the following code:
 
Code:
#ifndef HEADER_H#define HEADER_H/*Register declarations*/#endif

 This to prevent the linking errors for the header file being included more than once. Even though I've included this code to prevent this, I get a L1818 linking error saying that many registers were actually declared more than once.
I'm sure that all these registers are declered only once in the previous mentioned header file...
 
Is there some sorf of overriding command that ignored my #ifndef code? Is there a way to do something in IDE level?
 
Thanks for any reply,
 
Ivan.

 
标签 (1)
0 项奖励
回复
1 回复

736 次查看
CrasyCat
Specialist III
Hello
 
Make sure to have only external declaration for your registers in the .h file.
For example
  extern unsigned char PORTA;
 
You need a separate .C source file to hold the actual definition of the registers.
For example
  unsigned char PORTA;
 
 This is a standard programming rule, when you are using modular programming.
 
You can check the register definition file delivered with CodeWarrior to check how this is done.
 
CrasyCat
0 项奖励
回复