From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id B3E4B3858C55 for ; Tue, 1 Nov 2022 18:11:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B3E4B3858C55 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1035.google.com with SMTP id h14so13964638pjv.4 for ; Tue, 01 Nov 2022 11:11:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=iHUcbRv+KGGZ7qFBK53MNXiG9Vc7EUaxetHtMfjjjq8=; b=QV9Umi+s5L5SSf0Z7SwCbsCfLazqtd7bihFdjNZ0Nk/jNYctcagwYov4NhjdUeUbX8 O19MFETHWiMBTzdDRw2VIyi1oJEvxF0AMtdTB9o/ZUygLizEQEknVVZV08GtCgdd2+hK oGXzq1367zL747CdxFbplbdMcwzFLDXKyvWEdXFc6lwDDDLGy/j1AhUk9yW6F03tXrZC uybM22FGFnoFHfgRGpbI7pKs4EXPlZqzi4QIvlOUC4GiViZRIk0n9qFXYEikelrOdyH0 HgQYK0Elyg6Dotay2J+DP+jyr5yVzuBAkaevXbk6gBZOzd7AvhgEy+WhGCuqBKk8spqk c83g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=iHUcbRv+KGGZ7qFBK53MNXiG9Vc7EUaxetHtMfjjjq8=; b=TwinUVZS8/reRWMkS04Qm1Ex5md4eSUSU7JU4JLtCdZb0mzVXPWrI7+kOLq0zbbKQN EmwUhLXcjfifW1WXNWI8zOnQxXbpn4uKS8IxJgrG+/NPpIveo/OrXc/ARP3f3o1Zqg1x XSuGlTvofv1kkOSjXucOOtgc1g2oEF0c3ivZR9oFo/rgEYLtR+xTWOVXH7jkXeQ1o9E9 OByZeHi/ZxZNui5zZdoAHksbzQuHGEUm3Y878EChuti5tezTovAmx3yY6nVbK3Rk2hu7 y0JHaqUFlDPUCkz3sbh+IeTFpUsq5w5uh0AtjkCIqS82C/Nwgg3dHebzwnpWxCQDkXS7 6EFw== X-Gm-Message-State: ACrzQf0YTJ6FGfY/Adl/iVySXHKOjHjlzG1sI8J6AIH36ZGw38r7x+ZT SEmFYFj/szFdMLw8rnGoHpk= X-Google-Smtp-Source: AMsMyM4JgYoVbIFp0ik/Y2y6xENRFKtPsb+eWR5AodZ64BTxr1wMh4Ve7bMkPXyr0MM7icUjsMoVwg== X-Received: by 2002:a17:903:11cf:b0:178:a8f4:d511 with SMTP id q15-20020a17090311cf00b00178a8f4d511mr20579664plh.72.1667326306511; Tue, 01 Nov 2022 11:11:46 -0700 (PDT) Received: from lgmac-stevenwu.corp.netflix.com ([192.222.225.228]) by smtp.gmail.com with ESMTPSA id o24-20020aa79798000000b0056b8b17f914sm6796485pfp.216.2022.11.01.11.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 11:11:45 -0700 (PDT) Message-ID: Subject: Re: Issue with dllexport/dllimport inline function From: xclaesse@gmail.com To: LIU Hao , gcc@gcc.gnu.org Date: Tue, 01 Nov 2022 14:11:43 -0400 In-Reply-To: References: <845fde640ac4cd51c8bb50373f146987b3d26893.camel@gmail.com> <874c106a-41bb-afe6-44a1-d725fdcd583b@126.com> <88c1e389-8d80-38bd-e1fa-e61d2653da8d@126.com> <0c24f08964acc66a402d94c1b6a389dee4efa163.camel@gmail.com> <13cbf2ec-4027-3df7-aa76-3d680afc075b@126.com> <6c5778d2edfaa8b5196ef142ad0339ac6233b641.camel@gmail.com> <2ffea2dad5fa4da767276beb397405b1a7b151d1.camel@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu1 MIME-Version: 1.0 X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Oh, that seems to be working now. Still got a small issue, glib compiles with -Werror=3Dmissing- prototypes:=C2=A0 ../foo.h:7:5: error: no previous prototype for =E2=80=98g_strcmp0=E2=80=99 = [- Werror=3Dmissing-prototypes] I'm a bit lost with what the prototype would look like in this case. I think `__attribute__((__dllexport__))` will be needed when building with MSVC at least. Seems gcc, clang and msvc each wants a different trick :/ Thanks, Xavier Claessens. Le mercredi 02 novembre 2022 =C3=A0 00:06 +0800, LIU Hao a =C3=A9crit=C2=A0= : > =E5=9C=A8 2022-11-01 23:38, xclaesse@gmail.com=C2=A0=E5=86=99=E9=81=93: > > Thanks a lot for your help. > >=20 > > Sorry for late reply, but I gave your trick a try and it did not > > work: > > ``` > > /home/xclaesse/programmation/inline-example/builddir/../foo.h:7: > > multiple definition of `g_strcmp0'; > > libfoo.dll.p/foo.c.obj:/home/xclaesse/programmation/inline- > > example/builddir/../foo.h:7: first defined here > > ``` > >=20 >=20 > Apologies for the typo. The `__dllexport__` in 'foo.h' should have > been `__gnu_inline__`. If, for=20 > some reason, it needs to be specified explicitly, you may do that in > 'foo.c' instead. >=20 > 'foo.h': > =C2=A0=C2=A0=C2=A0 ``` > =C2=A0=C2=A0=C2=A0 #ifndef INSIDE_FOO_C > =C2=A0=C2=A0=C2=A0 __attribute__((__gnu_inline__)) __inline__ > =C2=A0=C2=A0=C2=A0 #endif > =C2=A0=C2=A0=C2=A0 extern > =C2=A0=C2=A0=C2=A0 int g_strcmp0(const char*str1, const char*str2) { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ... > =C2=A0=C2=A0=C2=A0 ``` >=20 > 'foo.c': > =C2=A0=C2=A0=C2=A0 ``` > =C2=A0=C2=A0=C2=A0 __attribute__((__dllexport__)) /* This is optional.=C2= =A0 */ > =C2=A0=C2=A0=C2=A0 extern int g_strcmp0 (const char *str1, const char *st= r2); > =C2=A0=C2=A0=C2=A0 ``` >=20 >=20 >=20 >=20 > --=20 > Best regards, > LIU Hao >=20