Reply by alexander_ribero●January 23, 20132013-01-23
From Keil uVision Help File:
Basic data types
ARM Compiler toolchain v5.02 for Vision Compiler Reference
This following basic data types are implemented in ARM C and C++:
Size and alignment of basic data types
Table 32 gives the size and natural alignment of the basic data types.
Table 32. Size and alignment of data types
Type Size in bits Natural alignment in bytes
char 8 1 (byte-aligned)
short 16 2 (halfword-aligned)
int 32 4 (word-aligned)
long 32 4 (word-aligned)
long long 64 8 (doubleword-aligned)
float 32 4 (word-aligned)
double 64 8 (doubleword-aligned)
long double 64 8 (doubleword-aligned)
All pointers 32 4 (word-aligned)
bool (C++ only) 8 1 (byte-aligned)
_Bool (C only[a]) 8 1 (byte-aligned)
wchar_t (C++ only) 16 2 (halfword-aligned)
[a] stdbool.h can be used to define the bool macro in C.
Type alignment varies according to the context:
Local variables are usually kept in registers, but when local variables spill
onto the stack, they are always word-aligned. For example, a spilled local char
variable has an alignment of 4.
The natural alignment of a packed type is 1.
See Structures, unions, enumerations, and bitfields for more information.
Integer
Integers are represented in two's complement form. The low word of a long
long is at the low address in little-endian mode, and at the high address in
big-endian mode.
Float
Floating-point quantities are stored in IEEE format:
float values are represented by IEEE single-precision values
double and long double values are represented by IEEE double-precision
values.
However, it would be better to use the standard definitions from stdint.h header
file, to be more portable.
Regards,
Alex
--- In l..., Sutton Mehaffey wrote: >
> Anybody have any input on this issue?
>
> Keil has 'char', 'short', 'int', and 'long
long' defined in their
> typedef.h file for ARM. I also see quite a few definitions in their
> header files of single 'long'. I assume that a single
'long' is the
> same as an 'int' in this case. At least that's what the Keil
debugger
> displays when monitoring data. But, I wanted to be sure, because I
> don't see any typedefs for a long in any of the header files. Any
> comments? Thanks.
> --
> Sutton Mehaffey
> Lookout Portable Security
> 4040 Royal Dr.
> Kennesaw, GA 30144
> 770-514-7999, 800-207-6269
> Fax: 770-514-1285
> http://www.lookoutportablesecurity.com
> sutton@...
>
Well, it's not necessarily a mistake. For a lot of programs, it's
sufficient to know that int is at least 2 bytes and long is at least four
bytes.
On Wed, Jan 23, 2013 at 1:54 AM, M. Manca wrote:
> **
> Il 23/01/2013 09:21, Paul Curtis ha scritto:
>
> >
> >
> >
> > On 22 Jan 2013, at 22:15, Sutton Mehaffey
> > s...@lookoutportablesecurity.com
> > > wrote:
> >
> > > Agreed. I should have added 'by the Keil ARM compiler that I
have'.
> > >
> >
> > Not really strong enough. int and long are distinct types which happen
> > to share the same machine representation in that particular
> > implementation.
> >
> > Anyway, no worries. :-)
> >
> Yes, the problem arises because C defines ambiguously short, int and
> long types. The original idea was to define them in function of the
> microprocessor data bus width. So int may be 16, 32 or 64 bit wide.
> Actually should be better to use inttypes.h or stdint.h that specify
> types in a better way specifying their bit width. In stdint.h there are
> a lot of integer types defined because it introduces the exact width,
> least width, maximum width (only one type of course) and fastest integer
> types definitions plus the pointer to the x integer type definition.
>
> So to be sure about the integers width the types to use should be exact
> width types:
> int8_t, int16_t, int32_t, int64_t and their unsigned variants: uint8_t,
> uint16_t, uint32_t, uint64_t
>
> >
> >
> > -- Paul.
> >
> > > Sutton Mehaffey
> > > Lookout Portable Security
> > > 4040 Royal Dr.
> > > Kennesaw, GA 30144
> > > 770-514-7999, 800-207-6269
> > > Fax: 770-514-1285
> > > http://www.lookoutportablesecurity.com
> > > s...@lookoutportablesecurity.com
> >
> > > On 1/22/2013 4:48 PM, Paul Curtis wrote:
> > >>
> > >> On 22 Jan 2013, at 21:22, Sutton Mehaffey
> > >> s...@lookoutportablesecurity.com
> >
> > >> > wrote:
> > >>
> > >>> Thanks. Good suggestion. Long and int are the same thing.
> > >>>
> > >>
> > >>> From a C perspective, long and int are not the same thing. They might
> > >> be realised by the same underlying machine representation, but they
> > >> are not the same. No way.
> > >>
> > >> Just saying.
> > >>
> > >> -- Paul.
> > >>
> > >>
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
Reply by "M. Manca"●January 23, 20132013-01-23
Il 23/01/2013 09:21, Paul Curtis ha scritto: >
> On 22 Jan 2013, at 22:15, Sutton Mehaffey
> s...@lookoutportablesecurity.com
> > wrote:
>
> > Agreed. I should have added 'by the Keil ARM compiler that I
have'.
> > Not really strong enough. int and long are distinct types which happen
> to share the same machine representation in that particular
> implementation.
>
> Anyway, no worries. :-)
> Yes, the problem arises because C defines ambiguously short, int and
long types. The original idea was to define them in function of the
microprocessor data bus width. So int may be 16, 32 or 64 bit wide.
Actually should be better to use inttypes.h or stdint.h that specify
types in a better way specifying their bit width. In stdint.h there are
a lot of integer types defined because it introduces the exact width,
least width, maximum width (only one type of course) and fastest integer
types definitions plus the pointer to the x integer type definition.
So to be sure about the integers width the types to use should be exact
width types:
int8_t, int16_t, int32_t, int64_t and their unsigned variants: uint8_t,
uint16_t, uint32_t, uint64_t > -- Paul.
>
> > Sutton Mehaffey
> > Lookout Portable Security
> > 4040 Royal Dr.
> > Kennesaw, GA 30144
> > 770-514-7999, 800-207-6269
> > Fax: 770-514-1285
> > http://www.lookoutportablesecurity.com
> > s...@lookoutportablesecurity.com
>
> > On 1/22/2013 4:48 PM, Paul Curtis wrote:
> >>
> >> On 22 Jan 2013, at 21:22, Sutton Mehaffey
> >> s...@lookoutportablesecurity.com
>
> >> > wrote:
> >>
> >>> Thanks. Good suggestion. Long and int are the same thing.
> >>>
> >>
> >>> From a C perspective, long and int are not the same thing. They might
> >> be realised by the same underlying machine representation, but they
> >> are not the same. No way.
> >>
> >> Just saying.
> >>
> >> -- Paul.
> >>
> >>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
Reply by Paul Curtis●January 23, 20132013-01-23
On 22 Jan 2013, at 22:15, Sutton Mehaffey
wrote:
> Agreed. I should have added 'by the Keil ARM
compiler that I have'.
>
Not really strong enough. int and long are distinct types which happen to share
the same machine representation in that particular implementation.
Anyway, no worries. :-)
-- Paul.
> Sutton Mehaffey
> Lookout Portable Security
> 4040 Royal Dr.
> Kennesaw, GA 30144
> 770-514-7999, 800-207-6269
> Fax: 770-514-1285
> http://www.lookoutportablesecurity.com
> s...@lookoutportablesecurity.com
> On 1/22/2013 4:48 PM, Paul Curtis wrote:
>>
>> On 22 Jan 2013, at 21:22, Sutton Mehaffey
>> s...@lookoutportablesecurity.com
>> > wrote:
>>
>>> Thanks. Good suggestion. Long and int are the same thing.
>>>> From a C perspective, long and int are not the same thing. They might
>> be realised by the same underlying machine representation, but they
>> are not the same. No way.
>>
>> Just saying.
>>
>> -- Paul.
>>
>>
>
>
Reply by Dimirtos Cherepanov●January 22, 20132013-01-22
2013/1/22 Sutton Mehaffey
> **
>
> Keil has 'char', 'short', 'int', and 'long
long' defined in their
> typedef.h file for ARM. I also see quite a few definitions in their
> header files of single 'long'. I assume that a single
'long' is the
> same as an 'int' in this case. At least that's what the Keil
debugger
> displays when monitoring data. But, I wanted to be sure, because I
> don't see any typedefs for a long in any of the header files. Any
> comments? Thanks.
> That is wrong with types ? Just see standart of C.
char is one byte
int is the main type and it is at least 2bytes
long int at least 4bytes
If you want to use STRICLY 32bits data type then use
uint32_t and uint64_t and so on also there is "uint_fast_8t" (is 32bit int
on arm)
--
CMake build environment project
for micro-controllers (use
it or
addyou
favorite MCU )
Reply by Richard Man●January 22, 20132013-01-22
Size of the data types are probably documented in the compiler doc
somewhere. If all else fails, you can always do
sizeof (long)
and see what the compiler generates.
On Tue, Jan 22, 2013 at 9:23 AM, Sutton Mehaffey <
s...@lookoutportablesecurity.com> wrote:
> **
> Anybody have any input on this issue?
>
> Keil has 'char', 'short', 'int', and 'long
long' defined in their
> typedef.h file for ARM. I also see quite a few definitions in their
> header files of single 'long'. I assume that a single
'long' is the
> same as an 'int' in this case. At least that's what the Keil
debugger
> displays when monitoring data. But, I wanted to be sure, because I
> don't see any typedefs for a long in any of the header files. Any
> comments? Thanks.
> --
> Sutton Mehaffey
> Lookout Portable Security
> 4040 Royal Dr.
> Kennesaw, GA 30144
> 770-514-7999, 800-207-6269
> Fax: 770-514-1285
> http://www.lookoutportablesecurity.com
> s...@lookoutportablesecurity.com
>
>
Reply by Sutton Mehaffey●January 22, 20132013-01-22
Agreed. I should have added 'by the Keil ARM compiler that I
have'.
Sutton Mehaffey
Lookout Portable Security
4040 Royal Dr.
Kennesaw, GA 30144
770-514-7999, 800-207-6269
Fax: 770-514-1285 http://www.lookoutportablesecurity.com
s...@lookoutportablesecurity.com
On 1/22/2013 4:48 PM, Paul Curtis wrote: >
> On 22 Jan 2013, at 21:22, Sutton Mehaffey
> s...@lookoutportablesecurity.com
> > wrote:
>
> > Thanks. Good suggestion. Long and int are the same thing.
> > >From a C perspective, long and int are not the same thing. They might
> be realised by the same underlying machine representation, but they
> are not the same. No way.
>
> Just saying.
>
> -- Paul.
Reply by Paul Curtis●January 22, 20132013-01-22
On 22 Jan 2013, at 21:22, Sutton Mehaffey
wrote:
> Thanks. Good suggestion. Long and int are the same
thing.
>
From a C perspective, long and int are not the same thing. They might be
realised by the same underlying machine representation, but they are not the
same. No way.
Just saying.
-- Paul.
Reply by Sutton Mehaffey●January 22, 20132013-01-22
Thanks. Good suggestion. Long and int are the same thing.
Sutton Mehaffey
Lookout Portable Security
4040 Royal Dr.
Kennesaw, GA 30144
770-514-7999, 800-207-6269
Fax: 770-514-1285 http://www.lookoutportablesecurity.com
s...@lookoutportablesecurity.com
On 1/22/2013 12:45 PM, M. Manca wrote: >
> Il 22/01/2013 18:23, Sutton Mehaffey ha scritto:
> >
> >
> > Anybody have any input on this issue?
> >
> > Keil has 'char', 'short', 'int', and
'long long' defined in their
> > typedef.h file for ARM. I also see quite a few definitions in their
> > header files of single 'long'. I assume that a single
'long' is the
> > same as an 'int' in this case. At least that's what the Keil
debugger
> > displays when monitoring data. But, I wanted to be sure, because I
> > don't see any typedefs for a long in any of the header files. Any
> > comments? Thanks.
> >
> The best thing to do is compare them using sizeof and some printf()...
> >
> > --
> > Sutton Mehaffey
> > Lookout Portable Security
> > 4040 Royal Dr.
> > Kennesaw, GA 30144
> > 770-514-7999, 800-207-6269
> > Fax: 770-514-1285
> > http://www.lookoutportablesecurity.com
> > s...@lookoutportablesecurity.com
>
> >
> >
> >
Reply by "M. Manca"●January 22, 20132013-01-22
Il 22/01/2013 18:23, Sutton Mehaffey ha scritto: >
>
> Anybody have any input on this issue?
>
> Keil has 'char', 'short', 'int', and 'long
long' defined in their
> typedef.h file for ARM. I also see quite a few definitions in their
> header files of single 'long'. I assume that a single
'long' is the
> same as an 'int' in this case. At least that's what the Keil
debugger
> displays when monitoring data. But, I wanted to be sure, because I
> don't see any typedefs for a long in any of the header files. Any
> comments? Thanks.
> The best thing to do is compare them using sizeof and some printf()... >
> --
> Sutton Mehaffey
> Lookout Portable Security
> 4040 Royal Dr.
> Kennesaw, GA 30144
> 770-514-7999, 800-207-6269
> Fax: 770-514-1285
> http://www.lookoutportablesecurity.com
> s...@lookoutportablesecurity.com
>