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.

Unresolved Symbols Remain

Hi there,

I'm having some trouble, and I think it's with C syntax...  I have a header file "System.h" which is included by multiple c source files (call them foo.c, bar.c).  

I'd like to define a struct "alpha" in System.h, and a global variable whose type is alpha in that header as well.  I'm not sure if global is the right word here...I'd just like to define a variable whose type is alpha that I can access and modify in foo.c and bar.c.  

This is what I have:

"System.h"

struct alpha

{

int a;

int b;

};

extern struct alpha myNewVariable;

"foo.c"

myNewVariable.a = 5;

"bar.c"

myNewVariable.b = 7;

CCS gives me the following error: 

error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking; "SeapHOX_source_files.out" not
built

What kind of error is this?  How can I fix my declarations?  Thanks!

-David

  • The structure should be declared as extern in the header file and then "defined" once in one of the C source files.

    So in either foo.c or bar.c, you should define the variable with:
       struct alpha myNewVariable;

    The you can reference it in other source files.

    Here is a related thread: http://e2e.ti.com/support/development_tools/compiler/f/343/p/91753/318712.aspx#318712

  • Ok, I have

    "System.h"

    extern struct alpha

    {

    int a;

    int b;

    };

    Then in foo.c (above my main) I have: struct alpha myNewVariable;

    But, then CCS tells me that identifier "myNewVariable" is undefined in bar.c.

    What's still wrong here? 

    Sorry, I'm pretty new to this stuff, and really appreciate all your help.  Thanks!

    -David

  • Did you make sure to #include "system.h" in both C files?

    I tried the following and it builds fine:

    system.h
    ------------

    struct alpha
    {
    int a;
    int b;
    };

    extern struct alpha myNewVariable;

    foo.c
    -------

    #include "system.h"
    struct alpha myNewVariable;

    main()
    {
     myNewVariable.a = 5;
    }

    bar.c
    ------

    #include "system.h"

    bar()
    {
    myNewVariable.b = 7;
    }