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 33289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T13:53:51+00:00 2026-05-10T13:53:51+00:00

I’m writing a C/C++ DLL and want to export certain functions which I’ve done

  • 0

I’m writing a C/C++ DLL and want to export certain functions which I’ve done before using a .def file like this

LIBRARY 'MyLib' EXPORTS   Foo   Bar 

with the code defined as this, for example:

int Foo(int a); void Bar(int foo); 

However, what if I want to declare an overloaded method of Foo() like:

int Foo(int a, int b); 

As the def file only has the function name and not the full prototype I can’t see how it would handle the overloaded functions. Do you just use the one entry and then specify which overloaded version you want when passing in the properly prototyped function pointer to LoadLibrary() ?

Edit: To be clear, this is on Windows using Visual Studio 2005

Edit: Marked the non-def (__declspec) method as the answer…I know this doesn’t actually solve the problem using def files as I wanted, but it seems that there is likely no (official) solution using def files. Will leave the question open, however, in case someone knows something we don’t have overloaded functions and def files.

  • 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. 2026-05-10T13:53:51+00:00Added an answer on May 10, 2026 at 1:53 pm

    In the code itself, mark the functions you want to export using __declspec(dllexport). For example:

    #define DllExport __declspec(dllexport)  int DllExport  Foo( int a ) {   // implementation } int DllExport Foo( int a, int b ) {   // implementation } 

    If you do this, you do not need to list the functions in the .def file.

    Alternatively, you may be able to use a default parameter value, like:

    int Foo( int a, int b = -1 ) 

    This assumes that there exists a value for b that you can use to indicate that it is unused. If -1 is a legal value for b, or if there isn’t or shouldn’t be a default, this won’t work.

    Edit (Adam Haile): Corrected to use __declspec as __dllspec was not correct so I could mark this as the official answer…it was close enough.

    Edit (Graeme): Oops – thanks for correcting my typo!

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

Sidebar

Related Questions

i want to parse a xhtml file and display in UITableView. what is the
I need to clean up various Word 'smart' characters in user input, including but
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.