|
Touché!
Cheers,
Vıkram.
Déjà moo - The feeling that you've seen this bull before.
Join the CP group at NationStates. Password: byalmightybob
|
|
|
|
|
I got it. =)
I knew right away you had to be from Hungary, with that sense of humor, haha.
|
|
|
|
|
And neither Italian, I can assure it!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
The Grand Negus wrote: Perhaps the guy changed the latter two types after the thing was running to fix a bug
Revision 1.0.
Cheers,
Vıkram.
Déjà moo - The feeling that you've seen this bull before.
Join the CP group at NationStates. Password: byalmightybob
|
|
|
|
|
Perhaps the guy was using his own convention. If he used it consistently, I don't think he is to blame.
Sorry I haven't noticed the long vars!!!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Well, long *is* integer data type
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
|
Hey, give the guy/gal a break. At least the variables have been initialised.
Chris Meech
I am Canadian. [heard in a local bar]
|
|
|
|
|
Well, accept for the naming this is not a coding horror. If he was coding for Windows before Vista, he would even be correct. The reason being that with VC6, and any compiler that created 32 bit code, an int and a long where the same thing.
I am not sure about a long but an int is supposed to be a machine word. In reality it depends on the compiler being used.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
But Hungarian notation used the l (or lng for the VBized version) to denote longs. Take this as an example, lpszMyText which stands for a Long Pointer to a String terminated by a Zero.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Do you know what a long pointer is? I do.
Hungarian notation has its uses, but it falls way short of what it was intended to do. In the case presented an int is probably 32 bit and an long is probably 32 bits, so coding wise it makes no difference until you start using a 64 bit compiler, in which case they will probably both be the same again.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
John R. Shaw wrote: Do you know what a long pointer is? I do.
So do I (having a C/C++ background here).
However, it is worth noting that there is a difference in the maximum/minimum allowed values between an int and a long. Try this in C#
Console.WriteLine(int.MaxValue.ToString());
Console.WriteLine(long.MaxValue.ToString()); So, look at the code again and tell me - do you think that an int and a long can be treated the same here?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
LOL! Sorry I tend not to notice the ‘.Net’ reference when looking at code that appears to be C or C++. Try that same logic in C or C++ and you will see it does not apply. When computers used 16 bit words an ‘int’ was supposed to be 16 bits as per language specifications (but actually it depended on the compiler). When they changed to 32 bit words (size of register) and new compilers came out, then ‘int’ became 32 bits per language specifications, which made it the same as a long. I do not know what artificial limits C# uses, but C and C++ uses register size and the compiler vendor sets the limits according to the standard. Any code you develop should be archived along with a copy of the compiler (environment) and the associated libraries, so that it can be recreated without having to modify it.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
John R. Shaw wrote: Try that same logic in C or C++ and you will see it does not apply.
I know - this caught me out a few times when I first moved over to .NET. I must admit that it really bugged me - especially when attempting to convert values.
.NET standardised on int being Int32 and long being Int64.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
What really bugs me some times is that even though the C and C++ languages are standardized the size of the types are not. That is even the size of ‘char’ is not guaranteed to be a byte, at least that is what Bjarne Stroustrup says and he should know.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Thank god for sizeof I say.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
You do know that ‘sizeof’ returns a number based on the ‘char’ size don’t you. Therefore if the character size was 16 bits then ‘sizeof(char)’ would still be 1 and not the number of bytes.
Isn’t non-specific specifications wonderful.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
char is 1 byte, by definition. However, this byte may not be one octet (8 bits), so that the system uses e.g. 9-bit (rare) or 16-bit (used on some DSPs) "bytes".
--
Marcus Kwok
|
|
|
|
|
Sorry to point this out, but that's by convention but not by the standard. All the standard states is that sizeof(short) <= sizeof(int) <= sizeof(long). Most implementations, however, have adopted the convention that an int is register size. However, a 32-bit compiler could choose short as 16-bit, int as 32-bit and long as 64-bit without breaking the standard, it just may not interoperate with code from other compilers very well.
Similarly char is a character - this could be 8-bit or 16-bit. In C++, they tend (I've never seen an exception) to be 8-bit, but the standard doesn't actually rule it out.
|
|
|
|
|
Rob Grainger wrote: Similarly char is a character - this could be 8-bit or 16-bit. In C++, they tend (I've never seen an exception) to be 8-bit, but the standard doesn't actually rule it out.
Some DSPs use 16-bit chars. Also, some weird machines (maybe it was the PDP-11?) use 9-bit chars. The standard just says that char is at least 8 bits.
--
Marcus Kwok
|
|
|
|
|
Thanks! I can never remember which systems use character sizes other than 8-bits, I just remember there are a few out there. Of course I know nothing more than that or even what language compilers support those systems.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I did not look it up, but at one time the C standard stated that an int was the size of a machine word and a short was 16-bits. I could be wrong, since it has be some years since I read it.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
John R. Shaw wrote: Do you know what a long pointer is? I do.
long pointers are used to access memory that is located in the other segment(intersegment).
Am I right?
Regards,
Arun Kumar.A
|
|
|
|
|
Actually no! Long pointers are not used any more and where used to overcome the limitations of PC memory access. The PC was limited to accessing only 64k, minus a few bytes for the systems use, so that was the max you could allocate with standard C (malloc). A normal pointer was only 16 bits, and a long pointer was a 32 bit pointer which required the compiler to generate code that allowed you to access more that 64k. Microsoft had the keyword ‘_far’ which told the compiler to make the pointer 32 bits instead of 16 bits and generate the required code. When Windows 95 came along and VC6 came out the ‘_far’ keyword was no longer supported, because it was not longer needed. All the ‘lp’ references in the code no longer mattered because all the pointers where now the same size, but if your previous code used the macro definitions like ‘LPSTR’ then it would still compile without error because the macros had been changed. If you had used the keyword ‘_far’ in any of your code, then you had to go in and remove it so you could compile the same code on the new compiler.
That is pretty much it, ‘lp’ means ‘p’ now days.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Thank you very much for your reply.
But, in C Language, how to access the memory 0xb8000000
which is the memory address for VDU.
Similarly , how to execute the POST function
located at 0xffff000 without far pointer?
Regards,
Arun Kumar.A
|
|
|
|