c2lang / c2compiler

the c2 programming language
c2lang.org
Apache License 2.0
704 stars 49 forks source link

function parameter cannot be of type array #114

Closed luarockr closed 4 years ago

luarockr commented 4 years ago

With new version of c2c (2020-05-25) it is not possible to use arrays as function parameters, with the previous version this was working well.

dhry.c2:154:38: error: function parameter cannot be of type array func void proc8(char[] array1par, ... <<< Now e.g. char* has to be used as parameter and call needs to give address of element at [0].

bvdberg commented 4 years ago

You're correct in that it doesn't work anymore. It not a bug, it because I changed the compiler to disallow arrays as function parameters.

The reason for this is that C doesn't actually copy the array, but uses pointers 'behind the scenes'. I want to get rid of this behaviour. So you could not use sizeof(param) to get the whole size and it was possible to pass char[10] into a function with parameter char[2]. So c2c now disallows it.