-1

I have the following code line:

typedef P2FUNC(Std_ReturnType, APP1, GetData) (P2VAR(max_data, AUTOMATIC, APP2)

whereby P2FUNC and P2VAR is a compiler Macro:

#define P2FUNC(rettype, ptrclass, fctname) rettype (*fctname)
#define P2VAR(ptrtype, memclass, ptrclass) ptrtype *

and max_data is defined as:

typedef uint8 max_data[];

The compiler gives me the following error:

error: parameter '<anonymous>' includes pointer to array of unknown bound     'max_data {aka unsigned char []}'

This .h files is included within a .cpp file within an extern"C"{ ...declaration.

My question now is, it is possible to disable this error message for this specific case? According some specific standard, this situation has it's own reason regarding the undetermined size of array.

I'm compiling with g++ compiler. Will be thankful for help.

JohnDoe
  • 825
  • 1
  • 13
  • 31
  • 2
    You can't disable *errors*, because they are errors, something you do that is simply not allowed. And you simply can't have pointers to arrays of unknown size. Either you need to rethink your design, make `max_data` an array of a specific size. – Some programmer dude Aug 07 '15 at 07:29

2 Answers2

2

When you pass arrays to functions, arrays gets implicitily converted to pointers, and you can't create pointers to array of unknown size.

To solve your issue, either give a size to your array typedef uint8 max_data[10]; or use pointers and dynamic memory allocation.

Nishant
  • 1,635
  • 1
  • 11
  • 24
1

Try defining max_data as:

typedef uint8* max_data;

of specify a size:

typedef uint8 max_data[10];
this
  • 5,229
  • 1
  • 22
  • 51