Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c,comp.programming.threads Subject: Re: Trivial C11 threads.h wrapper (public domain) Date: Mon, 01 Oct 2012 14:58:18 -0700 Organization: None to speak of Lines: 33 Message-ID: References: <50643C6A.6020609@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="5842a546a2d4559ed11e9ac4721da702"; logging-data="30580"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wb/0bCkljrweVyiAIT0pS" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:8B9JXhWHBjen1PpZ7NPcaupfAHk= sha1:hTa0LVok66e4JUJ23QsgfchiKuU= Xref: csiph.com comp.lang.c:26941 comp.programming.threads:1157 Toby Douglass writes: > In article <50643C6A.6020609@web.de>, Markus.Elfring@web.de says... >> 1. Would you like to provide a "typedef" for each enumeration? > > Enums have a type already and can only take a value in their range. > What's the advantage of a typedef? the disadvantage is extended the > type space. I believe that the intent of the enumeration constants defined by C11's is not to define enumeration *types*. It's merely to provide constants of type int with distinct values. If this were C++ rather than C, it's likely that they'd be defined as "const int" objects -- or, conversely, that the functions they're passed to would take arguments of an enumeration type. I presume, though the standard doesn't say so explicitly, that mtx_plain, mtx_recursive, mtx_timed are intended to have distinct values as are thrd_timedout, thrd_success, thrd_busy, thrd_error, thrd_nomem An enumeration type (without a tag or typedef) is an easy way to achieve that. Adding a tag and/or typedef would create a type name that's never actually used. Using that type for the parameters to the relevant functions would not provide any type safety. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"