Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c Subject: Re: C2 Aims to Modernize the C Language Date: Tue, 13 Feb 2018 07:30:19 +1300 Lines: 55 Message-ID: References: <20180211003235.f8b81e86a9275dd16af8eb40@gmail.com> <20180211044846.3164b7df534c8d6c3c127b49@gmail.com> <20180212000054.32bbfbfafa91930c5a09c41c@gmail.com> <20180212122916.ed1d64b3b64af5cd70bccb61@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 6QYUPoHsEEbx67jD5ql8iwKL1fLpLBsHFR+5QWtQEzqY7L1c5n Cancel-Lock: sha1:GGHmK6299zrGtoIVfG4DI1Irl8M= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.c:126609 On 02/13/2018 06:16 AM, bartc wrote: > On 12/02/2018 15:49, David Brown wrote: >> On 12/02/18 16:19, bartc wrote: > >>> A universal struct description shouldn't need to depend on using an >>> algorithm to determine offsets and padding. Or the size of a field. >>> >> >> The reality of C type sizes, paddings, alignments, etc., is extremely >> simple on almost all systems. > > That's why 'int' has a size which is 16 bits or more. That's why 'long' > is 32 bits or more. That's why int and long can be the same size, but be > different types. That's why 'char' might be signed. Or unsigned. Or has > a third kind of type which will be equivalent to signed or unsigned, but > can be incompatible with both. > > This is not what I call 'extremely' simple. Extremely simple would C2's > i8, i16, i32 and i64, with no padding and with no alignment requirements. > >> This is /not/ rocket science. It is not some evil conspiracy to cause >> you confusion. It is quite simple, and follows logical rules. > > Some counter examples; first from WinAPI: > > typedef struct tagBITMAPFILEHEADER { > WORD bfType; > DWORD bfSize; .... > > The 32-bit DWORD here is misaligned. > > The next is clock_t which has already been recently discussed at length, > in one case defined on top of several layers of typedefs and macros, > some conditional. (The problem being to determine the type and width in > order to duplicate that type elsewhere.) > > This is a declaration from MSVC's stdio.h: > > _Check_return_opt_ _CRT_NONSTDC_DEPRECATE(_fcloseall) _CRTIMP int > __cdecl fcloseall(void); > > I believe it is a function declaration with four lots of attributes. > (Can I just ignore them? I don't know.) As David said, you can hardly blame C for Microsoft's total screw up in this area. On Linux and Solaris we have extern int fcloseall (void); -- Ian. -- Ian.