dlsantos / dnp3

Automatically exported from code.google.com/p/dnp3
0 stars 0 forks source link

Use standard datatypes #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The datatypes listed in APL/DataTypes.h can be very architecture-specific.  It 
would be better for portability to use the standard C99 types where available.  
Microsoft Visual C++ does not support the stdint.h specification, so either a 
MSVC->C99 abstraction layer could be introduced or we could rely on a 3rd party 
library (like Boost) to provide this for us.

The advantage to using the MSVC->C99 trick is that most programmers are 
familiar with the C99 datatype names (int8_t, uint32_t, etc.) since they are 
standardized.  This would make it easier for other developers to pick up the 
project, rather than learning Boost naming conventions.

A sample of what this MSVC->C99 layer might look like is in commit 
70fec26c28a920425da2094b7c40ee98690aefe4.

Original issue reported on code.google.com by chris.ve...@gmail.com on 26 Apr 2011 at 7:16

GoogleCodeExporter commented 9 years ago
So, it looks like boost has an impl of cstdint that's cross platform. So it 
probably just imports <cstdint.h> as the change above does, but will handle 
windows for us and other platforms that haven't implemented C99.

From Wikipedia - the definitive source of truth in the universe :)

"The advantage of the use of <boost/cstdint.hpp> is that it can be used on many 
platforms. The code becomes naturally portable, and can be compiled on any 
platform without changes whenever the boost library can be used."

If that's the case, we can use it and do a global find/replace on the some of 
the types we use (i.e. change byte_t to uint_8, etc). I'm all for using the C99 
definitions throughout the code base. It think millis_t we can keep aroudn 
aliased as the C99 signed 64 bit Int.

Original comment by jadamcrain on 26 Apr 2011 at 7:43

GoogleCodeExporter commented 9 years ago
Added boost/cstdint.hpp to APL/Types.h in commit 
6841a324895db7b907a75fe645662adc119bc57b.  Mapping the C99 standard type names 
to the current project-specific ones.  This should offer us a little 
compatibility layer until we can do the major search-and-replace work.

Original comment by chris.ve...@gmail.com on 26 Apr 2011 at 8:00

GoogleCodeExporter commented 9 years ago
Partial update to last comment ... also use commit 
6c31aea93d06023795fda41e2397e7b512d04a3a, to fix a small typo.

Original comment by chris.ve...@gmail.com on 26 Apr 2011 at 8:02

GoogleCodeExporter commented 9 years ago
Executed find and replace on types, now using boost definitions for C99 types.

Resolved in vto branch. Will merge to trunk upon feature completion.

Original comment by jadamcrain on 27 Apr 2011 at 1:47