C1815 Error When Variable is Already Declared

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C1815 Error When Variable is Already Declared

Jump to solution
2,415 Views
AdrianoE
Contributor I

Hello,

 

I'm working on a project right now, and am having an annoying problem. The project is mostly done in C, with a few variable declarations in main.asm.

 

Codewarrior isn't recognizing the variables I'm declaring in main.asm. If I right-click the variable in main.c and select "Go to delcaration of X", it will go to the main.asm file where I declared it.

However, when I try to debug the project, the compiler says the variable hasn't been declared. Here are a few snippits of my code...

 

MAIN.ASM (the important variables here are the RAM_Lines)

 

; export symbols
            XDEF asm_main
            ; we use export 'Entry' as symbol. This allows us to
            ; reference 'Entry' either in the linker .prm file
            ; or from C/C++ later on

; Include derivative-specific definitions
        INCLUDE 'derivative.inc'          

            
; variable/data section
DEFAULT_RAM: SECTION
; Insert here your data definition.
;

temp_byte ds.b 1
RAM_line1 ds.b 16
RAM_line2 ds.b 16
RAM_line3 ds.b 16
RAM_line4 ds.b 16
SCI_RX_buf ds.b 16

; code section
MyCode:     SECTION

; this assembly routine is called by the C/C++ application
asm_main:
;          MOVB   #1,temp_byte   ; just some demonstration code
            NOP                   ; Insert here your own code

            RTC                   ; return to caller

 

MAIN.C

void main(void) {

EnableInterrupts;
asm_main();

 

strncpy(&RAM_line1[0],&line1[0],16);  //Before we start, we copy down the intro screen from
strncpy(&RAM_line2[0],&line2[0],16);  // flash into the RAM buffer used for the LCD
strncpy(&RAM_line3[0],&line3[0],16);
strncpy(&RAM_line4[0],&line4[0],16);                          

 

...

 

Once Codewarrior gets to strncpy(&RAM_line1[0],&line1[0],16);, it gives me an error (C1815), for all of the lines.

 

None of this is my code, it's code one of my teachers is having us put in our project. The project itself isn't about fixing this error, so I should be OK in posting this annoying error here.

 

Thanks in advance,

 

Adriano

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,177 Views
kef
Specialist I

This makes symbol asm_main visible to other modules:

 

            XDEF asm_main

without XDEF you would be unable to reference asm_main from any other C or ASM file. You should XDEF all variables you are trying to reference from main.c.

 

    XDEF  RAM_line1, RAM_line2, RAM_line3, RAM_line4

View solution in original post

0 Kudos
Reply
2 Replies
1,178 Views
kef
Specialist I

This makes symbol asm_main visible to other modules:

 

            XDEF asm_main

without XDEF you would be unable to reference asm_main from any other C or ASM file. You should XDEF all variables you are trying to reference from main.c.

 

    XDEF  RAM_line1, RAM_line2, RAM_line3, RAM_line4

0 Kudos
Reply
1,177 Views
AdrianoE
Contributor I

Sorry for the delayed reply, but thanks it does work now.

0 Kudos
Reply