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.

error #20: identifier is undefined

Other Parts Discussed in Thread: C2000WARE

Hi,

I have created a project in which I have done all the declarations in GV.h. And the definition of the variable in their respective .c files. For float, int, etc variable, There is no problem. But For an array, it's giving the "error #20: identifier is undefined".

The array "extern uint16_t BB_Port2_RX[10]" is declared in GV.h. And it's been initialized in vbus1.c. All the functions in vbus1.c are good. But when I used any BB_Port2_RX[x] in any other .c file, I am getting the error.

similarly, I have a structure" struct PORT" declaration In GH.h. But I was getting variable redefinition error in multiple .c files. But When I wrote their definition in main.c file, errors are gone. I wanna understand what is the problem? I see that many people are getting this issue.

Regard

Vishal

  • IIRC, you leave the size off for an extern declaration. You have to keep track of the size separately.

  • Please let me know if this FAQ (not from TI) resolves the problem.

    Thanks and regards,

    -George

  • Hi George,

    I did not touch my code. after some time, the errors are gone automatically. I will check the FAQ for a better understanding.

    I have another query. If I wanna have a C++ source file in my project, What changes do I need to make to my current project? I am using one of the example projects from driver lib. 

    After adding the C++ source file, I am getting the below warnings.

    Description Resource Path Location Type
    #2825-D conversion from a string literal to "char *" is deprecated .ccsproject /_CPU01_ELOAD2.0_EPR2_STRUCT line 1061, external location: C:\ti\C2000Ware_3_03_00_00_Software\driverlib\f2837xd\driverlib\sdfm.h C/C++ Problem.

    I wanna do this because I want functions inside a structure. Mentioned in the below link

    www.geeksforgeeks.org/.../

    Regards

    Vishal

  • I don't know exactly what causes the diagnostic ...

    conversion from a string literal to "char *" is deprecated

    But I can walk you through an example of it.  

    Consider this C (not C++) code ...

    char *p = "literal string constant";

    If you build it as C code, there are no diagnostics.

    % cl2000 file.c

    Build if you build it as C++ code ...

    % cl2000 --cpp_default file.c
    "file.c", line 1: warning: conversion from a string literal to "char *" is deprecated

    There are a few ways to address the problem.  One way is to use const char * instead ...

    const char *p = "literal string constant";

    Another way is to explicitly cast the string to char * ...

    char *p = (char *) "literal string constant";

    Thanks and regards,

    -George