使用KEIL編譯時(shí),出現(xiàn)*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS報(bào)錯(cuò)

使用的是CH559L芯片,用的是官方提供的CH559.h文件

報(bào)錯(cuò)信息如下:

image.png


遇到的情況如下:

1、經(jīng)過(guò)測(cè)試,如果有兩個(gè).c文件包含了CH559.h頭文件就會(huì)出現(xiàn)如上信息

2、報(bào)錯(cuò)的對(duì)象都來(lái)自于CH559.h

3、為了進(jìn)行模塊化編寫(xiě),又不能在一個(gè)C文件里寫(xiě)所有代碼,所以請(qǐng)教一下這個(gè)問(wèn)題要怎么解決啊j_0065.gif

The problem is that Keil c51 does Not Support a xsfr keyword. So you have to Work arround this.


The easy ugly way:

#define NO_XSFR_DEFINE

#include "ch559.h"

In all your c Files exept the first one to transate the xsfr defs to external declarations.


A better way would be to change ch559.h at the beginning with something Like this:

#ifdef __CH559_H__ //allready included somewhere

#define NO_XSFR_DEFINE

#endif

This way the header file itself will handle the changes.

I dont like the style of the original header files and therefore use my own ones.


@usbman還是不怎么懂,你用CH559.H可以發(fā)我一份嗎?j_0063.gif


你好,可以在CH559.h中增加NO_XSFR_DEFINE的宏定義。


Actually i forget to mention a third way.?

You may set NO_XSFR_DEFINE in the Keil IDE under?

options>Target>c51>defines globally vor all c files.?


Then change your main.c (and only that one)?

....

#undef NO_XSFR_DEFINE

#include "ch559.h"

....


By the way publishing my header files maybe does not make sense because i have designed them to be compatible with Keil, SDCC and IAR. Nothing vor a beginner i guess.


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频