From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12624 invoked by alias); 19 Jun 2006 05:38:04 -0000 Received: (qmail 12426 invoked by uid 22791); 19 Jun 2006 05:38:03 -0000 X-Spam-Check-By: sourceware.org Received: from gatekeeper.tait.co.nz (HELO gatekeeper.tait.co.nz) (202.37.96.11) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 19 Jun 2006 05:38:01 +0000 Received: from gatekeeper.tait.co.nz (localhost.localdomain [127.0.0.1]) by localhost.tait.co.nz (Postfix) with ESMTP id B245D46751 for ; Mon, 19 Jun 2006 17:37:58 +1200 (NZST) Received: from sunstrike.tait.co.nz (sunstrike [172.25.40.92])by gatekeeper.tait.co.nz (Postfix) with ESMTP id A0B8E46748for ; Mon, 19 Jun 2006 17:37:58 +1200 (NZST) Received: from conversion-daemon.sunstrike.tait.co.nz by sunstrike.tait.co.nz(Sun Java System Messaging Server 6.1 (built Apr 28 2004))id <0J1300D01D52QT00@sunstrike.tait.co.nz>(original mail from john.carter@tait.co.nz) for gcc-help@gcc.gnu.org; Mon,19 Jun 2006 17:37:58 +1200 (NZST) Received: from parore ([172.25.140.12])by sunstrike.tait.co.nz (Sun Java System Messaging Server 6.1 (built Apr 282004)) with ESMTP id <0J1300CNOEB9J300@sunstrike.tait.co.nz> forgcc-help@gcc.gnu.org; Mon, 19 Jun 2006 17:37:57 +1200 (NZST) Received: from localhost ([127.0.0.1] ident=johnc)by parore with esmtp (Exim 4.34) id 1FsCST-0001lP-Es for gcc-help@gcc.gnu.org;Mon, 19 Jun 2006 17:37:57 +1200 Date: Mon, 19 Jun 2006 05:38:00 -0000 From: John Carter Subject: What is the address of this line? To: gcc-help@gcc.gnu.org Message-id: MIME-version: 1.0 X-Mailer: Pidgeon Post Content-type: TEXT/PLAIN; format=flowed; charset=US-ASCII Content-transfer-encoding: 7BIT X-Apparently-From: mars X-Contents: May contain traces of nuts. X-imss-version: 2.040 X-imss-result: Passed X-imss-approveListMatch: *@tait.co.nz X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-06/txt/msg00146.txt.bz2 So we using gcc on an embedded platform. ie. Very constrained flash & ram. We also using asserts. Storing __LINE__ and __FILE__ is taking too much flash. Question: I would like to create an assert macro .... #define Assert( expression) do {\ if(!(expression)) { \ assert_occurred_at_program_counter = THE_ADDRESS_OF_THIS_LINE(); \ } } while(0) So how do I write that magical function / macro THE_ADDRESS_OF_THIS_LINE(); That returns the address / PC at that line? Preferable in a CPU neutral fashion, otherwise for a Sparc CPU. John Carter Phone : (64)(3) 358 6639 Tait Electronics Fax : (64)(3) 359 4632 PO Box 1645 Christchurch Email : john.carter@tait.co.nz New Zealand Carter's Clarification of Murphy's Law. "Things only ever go right so that they may go more spectacularly wrong later." >From this principle, all of life and physics may be deduced.