From owner-freebsd-questions@FreeBSD.ORG Thu Jan 17 00:28:53 2013 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 6C7DDC29 for ; Thu, 17 Jan 2013 00:28:53 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) by mx1.freebsd.org (Postfix) with ESMTP id 29CF3A92 for ; Thu, 17 Jan 2013 00:28:53 +0000 (UTC) Received: from r56.edvax.de (port-92-195-45-17.dynamic.qsc.de [92.195.45.17]) by mx01.qsc.de (Postfix) with ESMTP id 599023DC58; Thu, 17 Jan 2013 01:28:52 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id r0H0Sssl001976; Thu, 17 Jan 2013 01:28:54 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Thu, 17 Jan 2013 01:28:54 +0100 From: Polytropon To: "Thomas D. Dean" Subject: Re: time_t definition Message-Id: <20130117012854.1170d49c.freebsd@edvax.de> In-Reply-To: <50F71C5E.9040207@speakeasy.org> References: <201301161841.r0GIfgWS054810@mail.r-bonomi.com> <50F71C5E.9040207@speakeasy.org> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2013 00:28:53 -0000 On Wed, 16 Jan 2013 13:32:14 -0800, Thomas D. Dean wrote: > On 01/16/13 10:41, Robert Bonomi wrote: > > > *precisely* and the format string had "%ld". > > this IS a type mismatch, if a 'long' is a 64-bit value. > > The original code was compiled on a 32-bit machine for a 32-bit target. > I tried %d, %ld, and %lld with the same result. That's normal. As I did show in my previous message, (time_t) boils down to (int) which is as wide as the CPU architecture "naturally" uses it: On a 32 bit CPU, (int) is 32 bit, and on a 64 bit CPU, it's 64 bit. That's why you'll probably see something interesting when you use the source Luke for how the UFS file system stores time values: It uses (ufs_time_t) which is a typedef for (int64_t), a type that explicitely requires 64 bit, no matter if you're on a 32 bit CPU or a 64 bit CPU. Imagine it would be otherwise... ;-) > > FALSE. Calculation is OK. I/O format conversion is problematic. > > In the simple example I posted, gcc did not complain of a format mismatch. Because there was no format mismatch. > But, in the case of time_t gcc does complain of a format mismatch. As explained, this is _normal_. :-) > Both cases had the same number of typedef levels to get to a basic type > and used the same compile command. Should have the same result... It's not about the number of typedefs; it's about what it boils down to if you follow the chain to the machine level. :-) > I am attempting to understand the difference. Probably you will from my previous message. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...