From: xclaesse@gmail.com
To: gcc@gcc.gnu.org
Subject: Issue with dllexport/dllimport inline function
Date: Mon, 10 Oct 2022 12:39:21 -0400 [thread overview]
Message-ID: <f1c843ee6b97023927069a67de4ed1d0a7f27fa5.camel@gmail.com> (raw)
Hi,
I'm trying to dllexport/dllimport an inline function, but I get this
warning:
```
inline function ‘g_strcmp0’ declared as dllimport: attribute 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 != str2);
if (!str2)
return str1 != 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-with-dllexport-and-dllimport?view=msvc-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
next reply other threads:[~2022-10-10 16:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 16:39 xclaesse [this message]
2022-10-11 5:00 ` LIU Hao
2022-10-11 13:10 ` xclaesse
2022-10-11 13:28 ` LIU Hao
2022-10-11 13:35 ` LIU Hao
2022-10-11 14:26 ` xclaesse
2022-10-11 17:42 ` LIU Hao
2022-10-11 18:37 ` xclaesse
2022-10-12 3:03 ` LIU Hao
2022-11-01 15:38 ` xclaesse
2022-11-01 16:06 ` LIU Hao
2022-11-01 18:11 ` xclaesse
2022-11-02 4:44 ` LIU Hao
-- strict thread matches above, loose matches on Subject: below --
2022-10-10 16:32 xclaesse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f1c843ee6b97023927069a67de4ed1d0a7f27fa5.camel@gmail.com \
--to=xclaesse@gmail.com \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).