array of hex to Number in C++

Started by
12 comments, last by heh65532 11 years, 9 months ago
DWORD is a particularly awful name for a 32-bit integer. The machine word hasn't been 16 bits since the 80386, which came out in 1985. I understand keeping the label around in VC++ for compatibility, but I wouldn't use it.
Advertisement
In masm a word is still a 16 bit entity and that is where the names come from for MSVC++. But as I showed in an earlier post to be portable throughout your code you should redefine the primitive types to names of your own choosing as that will make your code compiler independent.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

Please don't. I can tell you from my experience, that this will give you a bad time. At a company I worked for, they had done this. They used an awful mess of conditional compilation to select the right typedefs for a given compiler and target processor. I tried to port code from 32 to 64 bits. I had to redo all the old type definitions (there were some for several 8 bit processors, a few 32 processors and so on). It was a pain in the ass.

There isn't a single sensible reason to define your own MY_INT32 or something similar. We have stdint.h and cstdint. They define everything you need. Types with guaranteed sizes and signedness. Redefining those types will also require you to include your type definition headers in each and every source file, thus slowing down the development process and compilation.

In order to improve readability of your code, you could define types for your function arguments. Like a typedef double Angle; or something like this. It won't keep you from passing the wrong type to your function, but it allows you to make the code easier to understand for a reader.
i'm just doing some windows GUIs. I wont port that so DWORD was useful definition and the win api uses it, so it should be perfect with win GUIs

This topic is closed to new replies.

Advertisement