Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 396325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:32:28+00:00 2026-05-12T16:32:28+00:00

Is there a cross platform way to selectively export certain functions and structs from

  • 0

Is there a cross platform way to selectively export certain functions and structs from a C project which builds a shared library?

I want to do in a way that does not require a specific build system (the visibility should be defined in the code, eg as a macro), and in a way which both GCC and MSVC can understand.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:32:29+00:00Added an answer on May 12, 2026 at 4:32 pm

    Strictly no, of course, because the toolchains aren’t the same.

    But people do this. The complexities are that in windows, you need to
    specifically tag the declarations of functions you want exported from
    a DLL with __declspec(dllexport) in the location in the library where
    the function is defined and __declspec(dllimport) in the locations
    in client code where the funciton is referenced. Because standard
    C practice has only one declaration in a single header file, this
    means that you generally need to do some macro work to have a single
    prefix that works in both locations. It seems like every project
    picks its own standard for this.

    On the Unix side, you don’t need to tag exports at all, which is nice.
    This is because every non-static function is exported by default,
    which is not so nice. Often you can get away with this as long as
    your non-public/non-static symbols have sane prefixes, which is what
    most projects seem to do. If you need finer control over your
    exported symbols, you can use a Solaris-style “mapfile” with the GNU
    linker’s –version-script (-M under solaris) argument to define explicitly which symbols should appear
    in the external namespace.

    There are a few more gotchas between the platforms, like the way the
    per-library global namespace works and the handling of
    startup/shutdown code. Basically, it’s a rats nest that can’t be
    sanely explained in a post this short, but as long as you’re careful
    that your library contains simple functions and your namespace doesn’t
    pollute, you shouldn’t have much trouble. Look to some of the more
    popular cross-platform shared libraries (e.g. Qt, Glib/Gtk+, anything
    distributed with msys, etc…) for guidance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 194k
  • Answers 194k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer foreach (string authornames in splitauthors) { litAuthors.Text = string.Format("{0}<br /><br… May 12, 2026 at 6:46 pm
  • Editorial Team
    Editorial Team added an answer problem was with the space, normal space ASCII value is… May 12, 2026 at 6:46 pm
  • Editorial Team
    Editorial Team added an answer Installing older versions is a pain. You have to grab… May 12, 2026 at 6:46 pm

Related Questions

Is there a (cross-platform) way to get a C FILE* handle from a C++
Is there a cross-platform way to list the processes running on one's computer through
I have to develop an application which parses a log file and sends specific
I've got a project that consists of two processes and I need to pass
I've had some trouble forking of processes from a Perl CGI script when running

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.