clang c11

Jamal Hadi Salim jhs at mojatatu.com
Fri Mar 20 22:44:31 CET 2015


On 03/20/15 15:09, Marc Lehmann wrote:

> Can you tell us more about your environment, e.g. do you embed libev, do
> you use the standalone version, does it compile without specifying extra
> flags, how do you configure it etc.?
>

we embed; nothing really interesting in terms of extra flags.

>  From what I see so far, I can only say that libev is not written in c11
> (c11 doesn't support file descriptors, event handling etc., so libev can't
> be written in c11, it needs platform-specific extensions, for example
> POSIX, but POSIX would be a bad choice on most platforms).
>

We are trying to use c11 with other standards of course. We have a 
requirement to make our code "c11 compliant". So thats where this comes
from (i.e by itself c11 doesnt support the things you mentioned; and
i wouldnt expect it to - but one could argue that neither does std c).

> I can't find a good description of what -std=c11 really does in the clang
> docs, but since libev doesn't select "c11 enforcement" mode itself, this
> looks like a user error - when you specify compiler flags, you have to
> select the correct compilation environment, and c11 simply isn't good
> enough.
>
> As such, failure is to be expected, and correct, i.e. it's a configuration
> error.
>

That was what i was curious about.
Note: I can make the problem go away with a simple patch:

--- a/ev.c
+++ b/ev.c
@@ -37,6 +37,9 @@
   * either the BSD or the GPL.
   */

+/* to get sigprocmask(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || 
_POSIX_SOURCE */
+#define _POSIX_SOURCE
+

Which i dont need if i dont specify -std=c11
It could be just specific to clang being pedantic (as opposed to
c11 specific).

>> It is trivial to pick one of the above and #define in ev.c but i dont
>> want to diverge on a private tree.
>> Is there some compile option perhaps i should be passing to make this go
>> away?
>
> Have you tried simply compiling in default mode for clang (i.e. no
> -std=c11)? That would probably fix it. Most likely, this problem is simply
> caused by -std=c11, as that likely tries to go into strict c11 mode, which
> is not enough to support libev (or any code trying to use it).
>

Yes, always works fine there.

cheers,
jamal



More information about the libev mailing list