|
Prev: Increment/ by C++
Next: reading text off file
From: Martin Røpcke on 13 Aug 2006 07:55 I need to find the register size of machine at runtime. Does anyone know a way to do this? Regards, Martin
From: osmium on 13 Aug 2006 09:49 "Martin Rpcke" writes: >I need to find the register size of machine at runtime. Does anyone know a >way to do this? I can't think of any way to come up with a definitive answer. The intent of the authors of the language was that a C int would be a "word', the most natural, that is register, size for a machine. But compilers for DOS and Windows stayed at 16 bits for an int even though the hardware was 32 bits. This went on for years, and even today there is all kinds of code for DOS and Windows that indicates a word is 16 bits. Microsoft even enshrined that relationship in their absurd Hungarian notation. If I really had to hammer this problem, I would look very carefully at the spec for the union. There might be some chink or clue in that area. But I think the best you will do is come up with what the compiler writer *thought* the register size was.
From: Andrew Koenig on 13 Aug 2006 11:13 "Martin Rpcke" <mrmr(a)diku.dk> wrote in message news:Pine.LNX.4.61.0608131354000.25599(a)brok.diku.dk... >I need to find the register size of machine at runtime. Why?
From: osmium on 13 Aug 2006 11:54 "Andrew Koenig" writes: >>I need to find the register size of machine at runtime. > > Why? I am surprised that the answer apparently depends on why he wants to know. Why does anyone want to know anything? Dogs seem to be happy and, AFAIK, they don't know much about anything. Could people be different than dogs?
From: r norman on 13 Aug 2006 12:20
On Sun, 13 Aug 2006 08:54:23 -0700, "osmium" <r124c4u102(a)comcast.net> wrote: >"Andrew Koenig" writes: > >>>I need to find the register size of machine at runtime. >> >> Why? > >I am surprised that the answer apparently depends on why he wants to know. > >Why does anyone want to know anything? Dogs seem to be happy and, AFAIK, >they don't know much about anything. Could people be different than dogs? The answer doesn't but perhaps the real need to know such a thing does. For example, if it is merely to try to optimize performance by declaring variables 'register', then the approach is probably misguided and the answer would be to better optimization techniques. On the other hand, if the original poster really must write hardware specific code, then he must already know the platform because such code is in no way portable between different CPU's. That would make the question irrelevant. On the third hand, if the person is trying to write code that might be portable across hardware platforms, then it might well be that the register size is not the proper test but looking for some special keyword #define created by the compiler might be a better technique. |