If, for some weird reason, you _have_ to use Hungarian in .NET, at least use it properly
-
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. :laugh:
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
Now days:
unsigned char* p = (unsigned char*)0xB8000000L;
Old days:unsigned char _far* p = (unsigned char _far*)0xB8000000L;
Used to do stuff like that all the time to directly access video memory and other hardware, but modern operating systems do not allow that any more. Accept for older code, which it places in a sandbox (its own processing space) so it can keep an eye on it, and even then it may not allow it. Direct access now requires a driver down at ring 0 to access hardware directly, but there is usually something like DirectX that does it for you. Note that both the addresses you mentioned are 32 bit and are therefore just ordinary pointers on a 32 bit machine.INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
-
Now days:
unsigned char* p = (unsigned char*)0xB8000000L;
Old days:unsigned char _far* p = (unsigned char _far*)0xB8000000L;
Used to do stuff like that all the time to directly access video memory and other hardware, but modern operating systems do not allow that any more. Accept for older code, which it places in a sandbox (its own processing space) so it can keep an eye on it, and even then it may not allow it. Direct access now requires a driver down at ring 0 to access hardware directly, but there is usually something like DirectX that does it for you. Note that both the addresses you mentioned are 32 bit and are therefore just ordinary pointers on a 32 bit machine.INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
Thank you very much. :):):)
Regards, Arun Kumar.A
-
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
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.
-
OK, I should've used the joke icon. If you take a look at my profile, I'm from Hungary. The joke was based upon the fact that Hungarian is not the same as Hungarian Notation.
-
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
-
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
-
The rule is best when used in spirit in more degree and emphasis than in letter. There used to be one lesson in my tenth standard English book "All about the dog". I forgot the author. It used to emphasize this letter vs spirit.
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
-
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.
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 ashort
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
-
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