This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CCS/EK-TM4C1294XL:链接外部函数和变量?

Guru**** 1812430 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/963733/ccs-ek-tm4c1294xl-linking-external-functions-and-variables

器件型号:EK-TM4C1294XL

工具/软件:Code Composer Studio

在我的应用程序中、我有 main.c 文件、而我有一个文件、Codes.c

codes.c 包含大量位模式、然后:

静态易失性 char tempcode [16384];
静态易失性 int CodeLength;
静态易失性 int CodeIdx;

void BuildCode (int CL){

int I;

CodeLength = CL;

tempcode[.]= bla.bla;
..

。}

在 main.c 中、我具有以下内容:

//链接到 Codes.c
extern void BuildCode (int CL);
extern char tempcode [16384];
extern int CodeLength、CodeIdx;


..
。

void CGsetupISR (void)
{
无符号短整型 NextData;
//Clr 中断
GPIOIntClear (GPIO_PORTQ_BASE、GPIO_PIN_2);

//Clr DC
GPIOPinWrite (GPIO_PORTQ_BASE、GPIO_PIN_0、0);

IF (代码负载= 1)
{
CodeIdx++;
IF (CodeIdx>CodeLength)
{
codeload=2;
返回;
}
}
其他
{
。

。} 

如果(CodeLoad=1)
NextData=tempcode[CodeIdx];
其他
。



void UploadCode (int len){
BuildCode (len);//将代码加载到缓冲区并复制7次

codeload=1;
CodeIdx=0;

SendFirstCGData();

}


这一切都可以编译、但进入链接阶段、我得到:
未定义 第一
个引用的符号 文件中
------ --------
CodeIdx /main.obj
CodeLength /main.obj
温度代码 /main.obj

我曾尝试过:

#include "Codes.c"

。 但是、我得到:

错误#10056:重新定义符号"BuildCode":首先在"./Codes.obj"中定义;在"./main.obj"中重新定义

这附带或不附带注释外部基准 该函数。

如何解决此问题?

电源 我曾尝试编辑排印错误、代码段中明显错误的格式等、但此编辑器确实不想编辑任何内容?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    静态变量.

    [引用用户="Ja HV"]

    staticvolatilechartempcode [16384];
    staticvolatileintCodeLength;
    staticvolatileintCodeIdx;

    [/报价]

    (笑声) 仅在定义它们的范围内可用。  在这种特殊情况下、它们仅在文件 Codes.c 中可用  要使它们在程序中处于全局状态、请删除 static 关键字。

    main.c 中写入与这些类似的行...

    [引用用户="Ja HV"]

    //Links to Codes.c
    externvoidBuildCode(intCL);
    externchartempcode [16384];
    externintCodeLength, CodeIdx;

    [/报价]

    (笑声) 通常不是如何完成的。  请使用 此常见问题解答中描述的方法 (不是 TI 提供的方法)。

    谢谢、此致、

    乔治