Skip to content

Structure Definition accessing in the test file #803

@kizhimonkp-ux

Description

@kizhimonkp-ux

Hi,

I have a source file called SourceA.c in which I have a structure definition and global structure object. I created a test file (test_SourceA.c) to test the SourceA.c and I have externed the global structure object but the compilation fails because the compiler cannot find the structure in the file which is understood. How are these issues generally tackled ? I know that I can simply move the structure definition to a .h file but I am just thinking if there is a better way as there is no need for the definition to be in the .h file.

SourceA.c is as shown below.

typedef struct
{
int A;
} structA;

StructA gtestSctruct;


void Func1()
{
  gtestSctruct.A = 1;
}

test_SouceA.c is as shown below:

extern StructA gtestSctruct;  //compilation error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions