sasagawa888 / eisl

ISLisp interpreter/compiler
Other
267 stars 22 forks source link

error: function definition is not allowed here #305

Closed yurivict closed 5 months ago

yurivict commented 5 months ago

Build prints this error:

In file included from library/tcltk0.c:41:
library/tcltk2.c:69:40: error: function definition is not allowed here
res = ({int res;int ITER(int X, int th){
                                       ^
1 error generated.

Build seems to tolerate these types of errors and succeeds, but the errors shouldn't occur.

Version: 3.70 FreeBSD 14.0

informatimago commented 5 months ago

Local functions are a gcc extension. clang has an option for block. With some macrology, you could generate either a local function or a block, but this has invasive implications, since pointers to functions must be converted to pointers to blocks, and pointers to blocks cannot point to functions. In gcc, a pointer to a function can point to a global or local function. It's probably not worth it.

So rewrite it using global functions, and yes, it means that any free variable must be moved as a global variable too, that must be assigned before calling the function.

Or stay with gcc until clang implements the same extension.

yurivict commented 5 months ago

Ok, thanks for this explanation.