From: Brian Dessent <brian@dessent.net>
To: Seyran Avanesyan <seyran.avanesyan@tanner.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: extern "C" From command line
Date: Fri, 22 Aug 2008 02:12:00 -0000 [thread overview]
Message-ID: <48AE1E8A.12ADDE12@dessent.net> (raw)
In-Reply-To: <D66102A43110FC488698F1C3B605E93108F961C0@exchange01.tanner.com>
Seyran Avanesyan wrote:
> Hi,
Please don't hijack threads; start a new thread. Changing the subject
line does not accomplish this. The mailing list archives on the gcc
website and any threaded email client will show your message as a reply
in a completely unrelated thread.
> Is there any way to make exported function names unmangled without using
> extern "C"?
>
> I'm compiling c++ file to a dll. Exported functions doesn't have extern
> "C" specified for them, so their names got mangled.
> The file cannot be edited.
>
> gcc -x c++ source.cpp -o source.o
> gcc -shared -o source.dll other_source.o source.o
>
> If I put required names into .def file but compile as c++ file, because
> of mangling I got errors: "Can not export ZZZZ: symbol not defined"
The mangling is there for a reason. If you exported a function with C++
linkage but without its name mangled then it's very likely that you
could call it from a compiler with a different C++ ABI, such as MSVC,
and that would fail. Mangling prevents this, because it requires that
to call the function you have a compiler with compatible ABI.
If your complaint is simply that you don't want to put mangled names in
the .def file, then I must ask: why use a .def file at all? It's
usually not needed. The GNU linker has auto-export enabled by default
which causes all symbols to be exported if __declspec(dllexport) is not
used anywhere. And if __declspec(dllexport) is used, then the source
itself already controls what functions to be exported so the .def file
is extraneous.
Brian
next prev parent reply other threads:[~2008-08-22 2:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-19 16:12 Restricting symbol binding within shared object Arindam
2008-08-19 16:58 ` special comments handling in the C compiler Tim Wang
2008-08-22 1:52 ` extern "C" From command line Seyran Avanesyan
2008-08-22 2:12 ` Brian Dessent [this message]
2008-08-23 1:38 ` Seyran Avanesyan
2008-08-23 2:37 ` Brian Dessent
2008-08-23 2:46 ` Seyran Avanesyan
2008-08-22 2:04 ` 64-bit gcc Seyran Avanesyan
2008-08-22 11:01 ` Brian Dessent
2008-08-22 20:09 ` Seyran Avanesyan
2008-08-22 22:32 ` Brian Dessent
2008-08-22 22:45 ` Seyran Avanesyan
2008-08-23 2:31 ` Brian Dessent
2008-08-23 2:45 ` NightStrike
2008-08-23 2:49 ` Seyran Avanesyan
2008-08-23 3:18 ` Brian Dessent
2008-08-23 2:00 ` NightStrike
2008-08-23 2:13 ` Seyran Avanesyan
2008-08-19 18:49 ` Restricting symbol binding within shared object Ian Lance Taylor
2008-08-20 19:36 ` Arindam
2008-08-21 4:43 ` Ian Lance Taylor
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=48AE1E8A.12ADDE12@dessent.net \
--to=brian@dessent.net \
--cc=gcc-help@gcc.gnu.org \
--cc=seyran.avanesyan@tanner.com \
/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).