www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/05/07:02:44

Date: Thu, 5 Feb 1998 12:00:42 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: David Shirley <shirleyd AT cs DOT curtin DOT edu DOT au>
cc: djgpp AT delorie DOT com
Subject: Re: Sizeof and pointers
In-Reply-To: <34D8C88E.2849A0A@cs.curtin.edu.au>
Message-ID: <Pine.SUN.3.91.980205120024.28596L-100000@is>
MIME-Version: 1.0

On Thu, 5 Feb 1998, David Shirley wrote:

> void func(unsigned char *tmp)
> {
> // BLAH BLAH
> }
> 
> How do i find how many bytes tmp is taking up in memory:

In general, you can't.  If you need to know the size of a function,
you will need to write it in assembly.  There's no C facility that you
can trust to get this functionality.

There is a hack you can use whereby you define two dummy functions,
before and after the one whose size you need to know, and then
subtract the addresses to compute the size.  But that is not
guaranteed to work, although it does in GCC 2.7.2.1.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019