简体   繁体   中英

Disable gcc error parameter '<anonymous>' includes pointer to array of unknown bound

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.

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.

Try defining max_data as:

typedef uint8* max_data;

of specify a size:

typedef uint8 max_data[10];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM