Arm Types Sizes?


cosurgi

http://janek.kozicki.pl/
Joined
Jul 30, 2008
Messages
1,098
Location
Gdansk, Poland
Website
janek.kozicki.pl
Hi, I've never been on ARM could you guys paste me the output of this code?

CODE
// gcc -o sizes sizes.c

int main()
{
printf("int %d\n",sizeof(int ));
printf("float %d\n",sizeof(float ));
printf("double %d\n",sizeof(double ));
printf("unsigned int %d\n",sizeof(unsigned int ));
printf("char %d\n",sizeof(char ));
printf("unsigned char %d\n",sizeof(unsigned char ));
printf("short %d\n",sizeof(short ));
printf("long %d\n",sizeof(long ));
printf("unsigned short %d\n",sizeof(unsigned short ));
printf("unsigned long %d\n",sizeof(unsigned long ));
printf("long double %d\n",sizeof(long double ));
printf("long long %d\n",sizeof(long long ));
printf("unsigned long long %d\n",sizeof(unsigned long long));
printf("void* %d\n",sizeof(void* ));
};


or this one, in C++:

CODE
// g++ -o sizes sizes.cpp -g -pthread

#include <iostream>
#include <string>
#include <vector>
#include <boost/thread/mutex.hpp>

using namespace std;

int main()
{
cout << "Type bytes" << endl;
cout << "------------------------" << endl;
cout << "int " << sizeof(int ) << endl;
cout << "float " << sizeof(float ) << endl;
cout << "double " << sizeof(double ) << endl;
cout << "bool " << sizeof(bool ) << endl;
cout << "unsigned int " << sizeof(unsigned int ) << endl;
cout << "char " << sizeof(char ) << endl;
cout << "unsigned char " << sizeof(unsigned char ) << endl;
cout << "short " << sizeof(short ) << endl;
cout << "long " << sizeof(long ) << endl;
cout << "unsigned short " << sizeof(unsigned short ) << endl;
cout << "unsigned long " << sizeof(unsigned long ) << endl;
cout << "long double " << sizeof(long double ) << endl;
cout << "long long " << sizeof(long long ) << endl;
cout << "unsigned long long " << sizeof(unsigned long long) << endl;
cout << "void* " << sizeof(void* ) << endl;
cout << "std::string " << sizeof(std::string ) << endl;
cout << "std::vector<int> " << sizeof(std::vector<int> ) << endl;
cout << "boost::mutex " << sizeof(boost::mutex ) << endl;
};


here's the output for various architectures that I managed to get so far:

CODE
C++(32) C (64)
Type ia32 amd64 PowerPC Sparc Sparc
-------------------------------------------------------------
int 4 4 4 4 4
float 4 4 4 4 4
double 8 8 8 8 8
bool 1 1 1 1
unsigned int 4 4 4 4 4
char 1 1 1 1 1
unsigned char 1 1 1 1 1
short 2 2 2 2 2
long 4 8 4 4 8
unsigned short 2 2 2 2 2
unsigned long 4 8 4 4 8
long double 12 16 8 16 16
long long 8 8 8 8 8
unsigned long long 8 8 8 8 8
void* 4 8 4 8
std::string 4 8 4
std::vector<int> 12 24 12
boost::mutex 24 40


thanks in advance :)
 
I haven't actually done this but I can tell you with high certainty that the numbers will be the same as PowerPC across the board. The last three are aggregate types whose sizes can be derived from the size of their components and the alignment/padding rules of the ABI - they're probably the same sizes as on ia32.
 
Last edited by a moderator:
Last edited by a moderator:
Here you go, running from a Beagleboard

CODE
root@beagle ~ # gcc -o sizes sizes.c
sizes.c: In function 'main':
sizes.c:3: warning: incompatible implicit declaration of built-in function 'printf'
root@beagle ~ # ./sizes
int 4
float 4
double 8
unsigned int 4
char 1
unsigned char 1
short 2
long 4
unsigned short 2
unsigned long 4
long double 8
long long 8
unsigned long long 8
void* 4
root@beagle ~ #
 
Here you go, running from a Beagleboard

CODE
root@beagle ~ # gcc -o sizes sizes.c
sizes.c: In function 'main':
sizes.c:3: warning: incompatible implicit declaration of built-in function 'printf'
root@beagle ~ # ./sizes
int 4
float 4
double 8
unsigned int 4
char 1
unsigned char 1
short 2
long 4
unsigned short 2
unsigned long 4
long double 8
long long 8
unsigned long long 8
void* 4
root@beagle ~ #
How dare you not to fix the warnings?

scnr
 
Last edited by a moderator:
Back
Top