EmbeddedRelated.com
Forums

ARM typedefs using Keil

Started by Sutton Mehaffey January 22, 2013
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

An Engineer's Guide to the LPC2100 Series

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
>



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
>
> >
> >
> >



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.

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.



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
>
>

--
// richard m: richard @imagecraft.com
// portfolio: >
blog: http://rfman.wordpress.com
// book: http://www.blurb.com/bookstore/detail/745963


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 )


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.
>>
>>
>
>
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.
> >>
> >>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
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.
> > >>
> > >>
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >