C1815 Error When Variable is Already Declared

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

C1815 Error When Variable is Already Declared

跳至解决方案
3,153 次查看
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

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,915 次查看
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 项奖励
回复
2 回复数
1,916 次查看
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 项奖励
回复
1,915 次查看
AdrianoE
Contributor I

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

0 项奖励
回复