[Gllug] c / sizeof structures / tool
Jonathan Harker
jon at jonathanharker.co.uk
Fri Jun 14 23:43:25 UTC 2002
On Friday 14 June 2002 6:31 pm, Simon Trimmer wrote:
> Someone must know this...
>
> Given a load of .h files, does anyone know of a tool to display the size of
> the structures?
>
> -Simon
> Simon Trimmer <simon at urbanmyth.org>
>
<disclaimer>
I do not know of any available tools.
I am NOT a perl head.
I am pissed.
It is late.
</disclaimer>
You could write a shell/perl/other script that writes and compiles a little
program for each .h you have. For each .h, look for (awk?) a sequence such as
struct X
class Y
and record and count the class/struct names. You don't want the ones that end
in semicolons as they're declared without being defined, eg.
struct DefinedElsewhere;
Once you've miraculously got the list of class/struct names, generate a
test.cpp file along the lines of
----------
#include <iostream>
using std::cout;
using std::endl;
// your script inserts the header file here:
#include <header.h>
int main()
{
// get your script to automate this for each class/struct name:
cout << "X has a size of " << sizeof(X) << endl;
cout << "Y has a size of " << sizeof(Y) << endl;
}
----------
Then compile it
(g++ -o test test.cpp)
and run the test program...
repeat for each .h
Hope that helps, bear in mind above disclaimer!
Luv Jon
--
Jonathan Harker
Web: www.jonathanharker.co.uk
ICQ: 30647378
MSN Messenger: jonathanischoice at hotmail.com
Yahoo & AIM chat: jonathanischoice
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list