问题
The following function declaration is accepted by gcc, but not accepted by g++.
void do_something(char (*)[]);
The error given by g++ is:
error: parameter '<anonymous>' includes pointer to array of unknown bound 'char []'
I believe that in C, the parameter is converted to char** which is why gcc accepts it fine.
Can I make g++ accept this function somehow?
See example: http://ideone.com/yqvqdB :)
Thanks!
回答1:
The GNU GCC compiler uses non-standard compilant to compile program. Add this flag -std=c99
or -std=iso9899:1999
to compile your program as a standard input and you will get an error.
In standard this will be always accepted as a pointer to an array, so you must provide the lenght of the array as it's required for pointers arithmitics.
来源:https://stackoverflow.com/questions/20570857/pointer-to-array-of-unknown-bound