dimitriv / Ziria

A domain-specific-language and compiler for low-level bitstream processing.
92 stars 18 forks source link

some externals are declared twice with different signatures #72

Closed pchickey closed 10 years ago

pchickey commented 10 years ago

In lib/externals.blk the functions copy_complex16, copy_complex32, copy_int16, and copy_int32 are each declared twice - in lines 134-137 and again in lines 143-146, with different signatures - the first set returns (), the second set returns int.

I assume only one of these sets of declarations is correct. Which one?

(I don't know enough about the blk language but perhaps it should also be a bug that this wasn't caught statically.)

bradunov commented 10 years ago

Good catch. Both are fine, but a compiler should catch this. And strictly speaking, the return should be (). I think that for some reason when a function returns () it is compiled in C as if it returns int32 and that int32 is not used. If you look at csrc/ext_arr.c, this is what happens, and the return is ignored. I think we should leave the declaration returning (), as the output should not be used, and fix the error catching.

pchickey commented 10 years ago

Thanks - I'll fix externals.blk myself and leave it up to someone else to look into the compiler.

The C compiler could have caught this issue except that the int and int32 sizes are the same on this platform, so multiple declarations of the same symbol is not reported.

edsko commented 10 years ago

See also #51.