Namespace Issues within an Extern block

Within an extern block, I tried to declare a routine called truncate. I got back

In file included from <built-in>:2:
s.chpl:39:22: error: static declaration of 'truncate' follows non-static declaration
        static inline float truncate (const float x)
/usr/include/unistd.h:1015:12: note: previous declaration is here
extern int truncate (const char *__file, __off_t __length)
1 error generated.
error: error running clang on extern block

That was not nice.

How many #includes get pulled in by defaul? How do I force it to none? I do not need any.

Thanks - Damian

Today, the implementation in the compiler includes effectively jamming all of the extern blocks into one C file. I think it's a reasonable point that this causes the problem you describe above. I'd recommend you make an issue about that since it's not trivial to address but your use case here is worth recording that way. (Or I could make an issue just pasting your example above. It does not need a lot more detail).

Anyway, I don't know of a quick workaround other than renaming your truncate function.

Thanks for the answer. I will change the name. Not the end of the world. Long term, I think it needs to be addressed.

Thanks again - I will raise an issue over the weekend

1 Like