From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128611 invoked by alias); 12 Dec 2019 09:49:28 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 128597 invoked by uid 89); 12 Dec 2019 09:49:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:727, H*Ad:D*126.com, H*F:D*126.com, transfer X-HELO: m15-111.126.com Received: from m15-111.126.com (HELO m15-111.126.com) (220.181.15.111) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Dec 2019 09:49:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Subject:From:Message-ID:Date:MIME-Version; bh=SJ6aW x2YR8oSKhtRAL+6d5hPqW/ElXdO0DnWxcKoWIU=; b=LStN7CfKJOOQWgmHLhGX9 kvKTnNaqem36G/nDBNNAe9WeQ/2tYd7IK/ubKfSeUVpBVPosY+PJd34te0p5n9z9 ycqUJ1RQctOTRc22oZJ3RMk/Ws8ywgPE2XpxtojkUgUysMQIheSHH6edRyWzjmXD J8aEXjVcAY57xQQPsnA94Y= Received: from [192.168.1.2] (unknown [101.86.246.75]) by smtp1 (Coremail) with SMTP id C8mowAA3e_0gDfJdad3+CQ--.302S2; Thu, 12 Dec 2019 17:49:21 +0800 (CST) Subject: Re: How to print pointer to function? To: Josef Wolf , gcc-help@gcc.gnu.org References: <20191212092116.GL2074@raven.inka.de> From: Liu Hao Openpgp: preference=signencrypt Message-ID: <1a9df1d1-df35-71e9-0f91-460e0728d62c@126.com> Date: Thu, 12 Dec 2019 09:49:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20191212092116.GL2074@raven.inka.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="M2ayKdjlz8UEzPuQABBC351sNUUMFJHFw" X-IsSubscribed: yes X-SW-Source: 2019-12/txt/msg00042.txt.bz2 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --M2ayKdjlz8UEzPuQABBC351sNUUMFJHFw Content-Type: multipart/mixed; boundary="aVnJ6gKvW0N0dozVPcJyK377cRponeZoH"; protected-headers="v1" From: Liu Hao To: Josef Wolf , gcc-help@gcc.gnu.org Message-ID: <1a9df1d1-df35-71e9-0f91-460e0728d62c@126.com> Subject: Re: How to print pointer to function? References: <20191212092116.GL2074@raven.inka.de> In-Reply-To: <20191212092116.GL2074@raven.inka.de> --aVnJ6gKvW0N0dozVPcJyK377cRponeZoH Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Content-length: 741 =E5=9C=A8 2019/12/12 17:21, Josef Wolf =E5=86=99=E9=81=93: > Hello, >=20 > I would like to print the pointer to a function for debugging purposes. >=20 > But I keep getting a warning: >=20 > ttt.c: In function 'insert_transfer': > ttt.c:7:37: warning: ISO C forbids conversion of function pointer to ob= ject pointer type [-Wpedantic] > 7 | printf ("lost transfer %p\r\n", (void*)rdyfunc); >=20 > Is there any way to get rid of this warning? >=20 Casting the point-to-function to `intptr_t` followed by `void*` will silence the warning: ``` printf ("lost transfer %p\r\n", (void*)(intptr_t)rdyfunc); ``` This may also help if you attempt to cast between different types of function pointers. --=20 Best regards, LH_Mouse --aVnJ6gKvW0N0dozVPcJyK377cRponeZoH-- --M2ayKdjlz8UEzPuQABBC351sNUUMFJHFw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEn9eDGptREvfrWRePQbMyeCIxW8QFAl3yDR0ACgkQQbMyeCIx W8SW6A//WRWAk3MMN4v5WAbj0h8KOBpWgaVE+R+IL2GmuvZ+J6gW6fOQ9vgQSVM6 AHsaX1E5Sx02IqXJPUyjgBLvFWQION/hYE+y9aUVxZKjNnEAwp9zEz50o6RkNG/H B1s/8Gwxjbhto+NwNYHsY+uf1HaMZPEwFM0vCkPl+TF+B+hEhvE/YfLZV2gJPddl 9eYlhYgZvEcNP4oOPIMHDBdu0nLR1DW8z8Z73OtXhmUsFvWUHLflNuTBhwRwWfp1 AGzTVe3ob1uOdUjDSiXi1yEcCSdqMrs+L2DSKIaWYtjgOLri5CuGY6nHmi5UY1Uk jCKp2e4eOuNccBRGAghnmSw6CfJuv7NVeM7cwuZyRWJ0q5dCKzr/v8+ciOlEqsC2 wYiUGJXzrNatXdCHl/+hjQaosbOBb0AA5k4ZeBo+kwV5zlzefRYMOodrgYNAMLJn fNYZODL57vjjacUDK2jAjUrQ6vrGpXys4ByrkyihSKUEFK9fiEZj7OJOQ9rcvT9I I9BmDvDddboPPDsnAOAc0YmJNgPQ64O2+8vDtXNZpJRPqSW4EqVdDLMYOd7tPr/o XaUQIJtsH5H2E25AV2+/RL2+cCZfeaNO7uvXktSrau48U+IyPHRWpXV1nVb8R7pW VximaJCFO/Jyk5CnVTIMam1OlfbHeGQyn3DVIk+4ulAod1z1n7Q= =dfod -----END PGP SIGNATURE----- --M2ayKdjlz8UEzPuQABBC351sNUUMFJHFw--