From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by sourceware.org (Postfix) with ESMTPS id 3D20D3858D37 for ; Mon, 10 Oct 2022 16:39:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3D20D3858D37 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-qt1-x831.google.com with SMTP id bb5so1445928qtb.11 for ; Mon, 10 Oct 2022 09:39:23 -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:date:to:from :subject:message-id:from:to:cc:subject:date:message-id:reply-to; bh=HtilFInLaNmOU96uRbD7mvBZ6vr3FyBUB1QEtYmh8L0=; b=S37gTXq+H8kvNEV8GnJU195Ra07+Ugmw66epwNujbvxw27ktxZ/Z4hgKWP3bf9js3D 7oesISmglaIpBMSyr7HVK+OoVjETSbInIwgnmOeGTtjOQxftQ+l5H5kh9R/T0km4vLKe 6n50yk1LyqwPv26K2OKb1hw5hs+7YScTgAEFUIfTme3zcwMtFye/3elDkEcfkwwfwpH+ WSysjLdiNpvuoDfqKPN4t8MHcnMwPXcwCkSrXavIKHXAO1pzNnaiemk5Hg6uFHwc5Loh wWjUEDhQfPV88+qZKTx6o+24DIbKQ1a7rB+7lWEPsY6Xk4/NepmIVpStrMMl3k+x/s/D 1tXA== 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:date:to:from :subject:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HtilFInLaNmOU96uRbD7mvBZ6vr3FyBUB1QEtYmh8L0=; b=IyIwyh3WQTIrNiBRfW59lmnT7vzzonCqskGn9KrgpsxdPBoYx23psgg+zht+87g8JO UuoNrmekbeVnzlMWJ6AbuY13mfHwMdrRCztqZnLIEQ595dl2vTe5dwAWbWGByk8Iu8uS 4lfR+OjejH6NQRUi91xsLaGSlqqgY2JhEFWE5bB6GrWR1IzsOjo86V+WKQbET+I/fkeR tcnIXuvLUyoiNhVLL3O+gEUnFInEphsK4oUJ1JDQHjAjHM+veUfktx5d9ZZPKIInx5+r pp2gfCjxoUnqquf4cCy/UqmwRs4twfqsw32VmCIpPmKqcVuJ6u2rmniVKTgGhqrilFqI OxVw== X-Gm-Message-State: ACrzQf0EdpXDpHXSBnPXRtShduiTWE0K0o/XRzHNUeFJD5JZhCKMo0/7 YcKU/sggZKcFw7D04ljrMm1fvQ/vDJI= X-Google-Smtp-Source: AMsMyM6dxbNVZFa0KJ+Y16N8jxWpgh0Xbfpm055byZ1+VmwurnTSDSmMBYrrzn1Djbbk22FF1knwLg== X-Received: by 2002:ac8:5982:0:b0:395:3669:eb3c with SMTP id e2-20020ac85982000000b003953669eb3cmr15640246qte.213.1665419962300; Mon, 10 Oct 2022 09:39:22 -0700 (PDT) Received: from [192.168.0.2] ([192.222.225.228]) by smtp.gmail.com with ESMTPSA id v1-20020a05620a0f0100b006bb8b5b79efsm10896353qkl.129.2022.10.10.09.39.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 09:39:21 -0700 (PDT) Message-ID: Subject: Issue with dllexport/dllimport inline function From: xclaesse@gmail.com To: gcc@gcc.gnu.org Date: Mon, 10 Oct 2022 12:39:21 -0400 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=1.6 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,URI_TRY_3LD autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, I'm trying to dllexport/dllimport an inline function, but I get this warning: ``` inline function =E2=80=98g_strcmp0=E2=80=99 declared as dllimport: attribut= e ignored [- Wattributes] ``` This is when cross compiling my code on Linux for Windows using mingw. The relevant code is ``` GLIB_API inline int=C2=A0=C2=A0=C2=A0=C2=A0 g_strcmp0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (const char=C2=A0=C2=A0=C2=A0=C2=A0 *str1, =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 const char=C2=A0=C2=A0=C2=A0=C2=A0 *str2) { =C2=A0 if (!str1) =C2=A0=C2=A0=C2=A0 return -(str1 !=3D str2); =C2=A0 if (!str2) =C2=A0=C2=A0=C2=A0 return str1 !=3D str2; =C2=A0 return strcmp (str1, str2); } ``` Where GLIB_API is defined to `__declspec(dllexport)` when compiling the DLL and `__declspec(dllimport)` when including the header from application. The goal is to get that function inlined when doing `if (g_strcmp0(a, b))`, but get address from instance in the DLL when doing `do_sort(array, g_strcmp0)`. I believe dllimport of inline function should be supported, it compiles fine with MSVC. It is even documented there: https://learn.microsoft.com/en-us/cpp/cpp/defining-inline-cpp-functions-wit= h-dllexport-and-dllimport?view=3Dmsvc-170 I believe (but not tested myself) that clang had the same issue but got fixed years ago: https://reviews.llvm.org/D3772 For context, I'm hitting this issue when working on that GLib patch: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2926 Is there a trick to get that working with GCC? Or should that issue be reported somewhere? Regards, Xavier Claessens