Cosmic Compiler Port

cancel
Showing results for 
Search instead for 
Did you mean: 

Cosmic Compiler Port

1,633 Views
Ken32
Contributor I
Hi,
I'm trying to port a MicroC OS II project from Cosmic CrapPiler to Codewarrior. I'm getting like 51 L1818 errors.
Here's an example of one...
Link Error   : L1818: Symbol 241 - PORTA duplicated in OS_FLAG.C.o and OS_CORE.C.o

I have no idea why its doing this. I have PORTA defined in iosc32.h which is a Cosmic include file.

Here's part of the source:
/*    IO DEFINITIONS FOR MCS912C32
 *    Copyright (c) 2003 by COSMIC Software
 */
#ifndef _BASE
#define _BASE    0
#endif
#define _IO(x)    @(_BASE)+(x)

typedef unsigned char __uchar;
typedef unsigned int __uint;

/*    MEBI Module
 */
volatile __uchar PORTA       _IO(0x00);   /* port A */
volatile __uchar PORTB       _IO(0x01);   /* port B */
volatile __uchar DDRA        _IO(0x02);   /* data direction port A */
volatile __uchar DDRB        _IO(0x03);   /* data direction port B */
volatile __uchar PORTE       _IO(0x08);   /* port E */
volatile __uchar DDRE        _IO(0x09);   /* data direction port E */
.
.
.


So PortA is defined here...and not in OS_FLAG.c.o or that other file. Infact its not even used in any of those files? Anyone know what this is?
Also I have not set any linker settings...not sure how that's done here. I heard that Codewarrior links for you?
Labels (1)
Tags (1)
0 Kudos
3 Replies

27 Views
Stephen
Contributor III
Hi Ken
Just looked at your code - happens to be very similar to an issue I have been sorting out with a colleague who has previously used a different compiler. Can I suggest the following change:
 
Here's part of the source:
/*    IO DEFINITIONS FOR MCS912C32
 *    Copyright (c) 2003 by COSMIC Software
 */
#ifndef _BASE
#define _BASE    0
#endif    <- MOVE THIS STATEMENT to the end of the file
#define _IO(x)    @(_BASE)+(x)

typedef unsigned char __uchar;
typedef unsigned int __uint;

/*    MEBI Module
 */
volatile __uchar PORTA       _IO(0x00);   /* port A */
volatile __uchar PORTB       _IO(0x01);   /* port B */
volatile __uchar DDRA        _IO(0x02);   /* data direction port A */
volatile __uchar DDRB        _IO(0x03);   /* data direction port B */
volatile __uchar PORTE       _IO(0x08);   /* port E */
volatile __uchar DDRE        _IO(0x09);   /* data direction port E */
.
.
.
#endif  /* _BASE */   <- put the statement here
 
Now the first time the compiler goes through the file, it will define _BASE and process the rest of the header. The second time the compiler opens the header file, it sees _BASE is defined and skips everything else.
 
IMHO the CodeWarrior compiler is more strict (sensitive) about stuff like this.
 
Good luck with your coding
Steve
0 Kudos

27 Views
CompilerGuru
NXP Employee
NXP Employee
Hi Steve,

I think you misunderstood here what _BASE is for.
I dont think this is the multiple time inclusion guard, instead for the S12's, the register block is moveable and this _BASE is a way an user could adapt this library to use an alterative base address.

Daniel
0 Kudos

27 Views
CompilerGuru
NXP Employee
NXP Employee
CW wants for every variable one definition, but your header is
currently defining all the variables (and not just declares them). Basically
absolute allocated variables with @ are behaving not different from any other variable (or function).
To fix your case, the simplest is to add an extern, which is disabled for all but a single use case.
E.g. something like:


Code:
// header.h#ifndef DEFINE_VARS_IO#define EXT_IO extern#else#define EXT_IO#endif...EXT_IO volatile __uchar PORTA       _IO(0x00);   /* port A */EXT_IO volatile __uchar PORTB       _IO(0x01);   /* port B */....and in  one C file, or in a new dedicated one:#define DEFINE_VARS_IO#include "header.h"


Daniel
0 Kudos