From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by sourceware.org (Postfix) with ESMTPS id 050DB385383C for ; Tue, 11 Oct 2022 12:00:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 050DB385383C 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-qv1-xf2f.google.com with SMTP id z18so8774289qvn.6 for ; Tue, 11 Oct 2022 05:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=user-agent:date:mime-version:content-transfer-encoding:to:from :subject:message-id:from:to:cc:subject:date:message-id:reply-to; bh=B/5pYQfvs28BcbEeMRZ0aNhVP9Y7rLMYo8FX1+ALq/g=; b=Zu/B0YGiZrWL801BB6p/2ODHiFGeN0uu1mVOTKa7gj6JD7YYMAwyAShkv9/wcMAUEe tcjHPO+Y4ttqT1e4DBjnLAQxMOwgcaLKN6mEPHXP4cvpVIN8W9SRM8yQZvj4pGng8c5o EXB1thYDj6ULKkeLCx1iRDek3ATrBBc3oZzeAsZd+zF/U1vDfNA4nQYMeqcsCvD1KiVz 1X9JzotFPBcIHpj8uDrxhLQ4N1N6x/ChFhT6EZbbGkUjRquj+pgWHByqguzS1jdbm6pY SIhR47e4oxCjIcRvMYiaoM8bLX4X6J5Yib6vT7EeDWLTRqMGhiNu56pf/rVTH8+yZMCv bX2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:date:mime-version:content-transfer-encoding:to:from :subject:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=B/5pYQfvs28BcbEeMRZ0aNhVP9Y7rLMYo8FX1+ALq/g=; b=eFCCvfR+OWOakQdXBf1g79CN+BPwTVG9diud3dBlQbAROZH4HjjaoimnAaRcFZgswx ZwvZUZrbGwr2okqltkrM70XT5xKmlLoizeofX/kQCwr7qcTO+fcMHX1X+Wwiej6fchoy UUjNxrycJGzP0XwZRBubpQaKbR/jdtDSRL+f2AfE8qluglxS+79Tz9QNPMbOEGMnkyld wjCe/X12hdNU1wPp3i7BX1ddz9CFHJvaxamcD+GRETzix/sENZspruBjBqAJqvo/EAPS anXLR1+z8ZYrCqQo19M8w5Lvi0YAE9HLv0KUReqhI3FBZ6LnK9AJfemWTCT9BGNY0N9A i+ag== X-Gm-Message-State: ACrzQf2Gk+EBKIEVvpbXAna+PdAQKpLQJxv0wGHnLuSp9fXZU55ULQEh it65PwZ6blUf73ceN3yHKkXXAV8LHPw= X-Google-Smtp-Source: AMsMyM70IHHoPipM25RtsYgUtkl0rOok1NIoP1jpabKlw42P+uvGRrr7iQ8p+2+ge6JTGXHjoT6MKg== X-Received: by 2002:ad4:5ca2:0:b0:4b1:91d7:3d35 with SMTP id q2-20020ad45ca2000000b004b191d73d35mr18374372qvh.34.1665489638471; Tue, 11 Oct 2022 05:00:38 -0700 (PDT) Received: from [192.168.0.2] ([192.222.225.228]) by smtp.gmail.com with ESMTPSA id j4-20020a05620a410400b006a6ab259261sm13058019qko.29.2022.10.11.05.00.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 05:00:38 -0700 (PDT) Message-ID: <50a8ea234841205fcf2aeeed7e850450c3126072.camel@gmail.com> Subject: Issue with dllexport/dllimport inline function From: xclaesse@gmail.com To: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Date: Mon, 10 Oct 2022 12:32:40 -0400 User-Agent: Evolution 3.44.4-0ubuntu1 X-Spam-Status: No, score=1.9 required=5.0 tests=BAYES_00,DATE_IN_PAST_12_24,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 g_strcmp0 (const char *str1, const char *str2) { if (!str1) return -(str1 !=3D str2); if (!str2) return str1 !=3D str2; 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