1

In file "cerberOS_BSP.h" I have the following:

extern char cmp_ids[][];
extern UInt8 periph_list[];

In file "BSP_unpnp.c", I have:

UInt8 periph_list[AMOUNT_OF_PERIPH] = {0};
char cmp_ids[MAX_CMPS][4] = {0};

This gives no errors for periph_list but gives the following for cmp_ids:

../../uJ/cerberOS_BSP.h:55:13: error: array type has incomplete element type
 extern char cmp_ids[][];

Unsure on how to solve this since I don't fully understand the issue, any ideas?

1

2 Answers 2

0

In the case of …

char cmp_ids[][];

… you have two dimensions with open (unspecified) size. Since the location of an element is calculated by start + index * sizeofelements, it is necessary to know the size of the elements.

The element of the outer array is the inner array char[]. The size is not known.

You can only omit the most outer size. All other sizes have to be specified.

Sign up to request clarification or add additional context in comments.

1 Comment

Assuming by "omit the most outer size" you mean the indice that comes first. myarray[ ][123] is valid, myarray[123][ ] is invalid.
-1

An array must be declared with a size, for instance:

extern char cmp_ids[MAX_CMPS][4];
extern UInt8 periph_list[AMOUNT_OF_PERIPH];

Therefor, in the header file you need to add (or include) the definitions of MAX_CMPS and AMOUNT_OF_PERIPH. If the sizes need to be calculated at run-time you can instead use pointers:

extern char **cmp_ids;
extern UInt8 *periph_list;

2 Comments

The declaration can omit the size of the most outer dimension. Therefore there is no error for periph_list.
@AminNegm-Awad That's correct. However, without the size of the first dimension there is no way to tell the length of the array in the client module; sizeof is not applicable to incomplete types like UInt8[].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.