POV-Ray : Newsgroups : povray.off-topic : Invisible: PureData : Re: Invisible: PureData Server Time
3 Sep 2024 19:19:28 EDT (-0400)
  Re: Invisible: PureData  
From: Darren New
Date: 16 Feb 2011 15:07:37
Message: <4d5c2e89$1@news.povray.org>
Warp wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>> You do. They just wrote into the standard that there's a header file that 
>> comes with the compiler that says "Hey, when he says uint64_t, he means long 
>> long unsigned int".
> 
>> You can't declare a 64-bit integer. You can use someone else's declaration 
>> that the standard says gives you a 64-bit integer in terms of 
>> compiler-dependent long long unsigned int sorts of things.
> 
>   Again with your fixation about "someone else's" declaration.

I'm trying to clarify for Andrew what's going on. He said "In C, I say... 
um, well it seems to vary by compiler/OS. WTF?"  And he's right. Except that 
there's also part of the standard that says the compiler comes with a bit of 
library code to let you write code that selects the right "thing that varies 
by compiler" to give you the 64 bits you're looking for.

>   Whether uint64_t is declared in a header file or whether it's a reserved
> keyword supported by the compiler directly makes little difference.

It only makes a difference if you actually want to understand what's 
actually going on. If you're happy to do cargo-cult programming, then no, 
you don't have to understand that uint64_t is a typedef and "long int" isn't.

For example, if Andrew now goes and declares something as "uint64_t" in his 
program, it won't work, because you didn't tell him the right header to 
include to get that declaration, while "long long int" will continue to work 
because it needs no declaration prior to use.

In other words, I'm pointing out that uint64_t is in a standard library, not 
part of the language per se. It's clear that "all the sources" Andrew looked 
at didn't mention that this is in the library but rather were talking 
specifically about the language itself.

 > It's *standard* in any case. You can use it safely.

I didn't say you couldn't. I said that C per se doesn't let you declare "a 
64-bit integer", in contrast to many other languages that do.

I'd also argue that C, per se, doesn't support I/O, but it comes with a 
standard library that does and which you can rely on. Would you gripe at me 
for clarifying that for someone coming from a Pascal or Fortran background?

>   (And besides, nowhere it is said that 'long long' must be 64 bits in size.)

Which is exactly what prevents you from declaring a 64-bit integer and 
instead requires the standard to define a typedef from some arbitrary 
compiler-specific declaration to a standard name that will give you 64 bits. 
The very fact that nowhere it is said that "long long" must be 64 bits in 
size is exactly what has Andrew going "WTF?"  Explaining the solution half 
way is likely to be more confusing and (ime) would tend to lead to someone 
thinking they don't actually understand the language as much as they do, 
thinking they missed something in the language rather than simply having an 
incomplete understanding of the extensive standard libraries.

-- 
Darren New, San Diego CA, USA (PST)
  "How did he die?"   "He got shot in the hand."
     "That was fatal?"
          "He was holding a live grenade at the time."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.