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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:51:40+00:00 2026-05-18T08:51:40+00:00

Here’s my scenario: I have made a regular DLL in C++ (using VS2008) which

  • 0

Here’s my scenario:

I have made a regular DLL in C++ (using VS2008) which provides C interface to exported functions. Two of the concerning functions are 1. initialize() and 2. uninitialize()

Inside initialize() I have to take some parameters from client application. So far, I could think of following two ways to do this:

First way:

I make a structure, fill it and pass object/pointer of the structure object to the DLL from client application.

    struct SData
    {
        DataType param1;
        DataType param2;
        DataType param3;
        DataType param4;
    };

Second way:

I export 4 functions from my DLL like

    SetParam1(DataType param1)
    SetParam2(DataType param2)
    SetParam3(DataType param3)
    SetParam4(DataType param4)

Which way or some other should I use, please suggest.

  • 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-18T08:51:40+00:00Added an answer on May 18, 2026 at 8:51 am

    Since DLL shares the address space with your application, you can handle it all just by sending a pointer to your struct. If you happen to use different version of the DLL with your application you might also employ some kind of version checking in your function to avoid getting mixed up by different versions of it.

    I personally do not recommend SetParam(param1) method because it implies a global scope in the DLL thus is not thread-safe. On the other hand passing all parameters to the function itself has a local scope, less prone to bugs, more contained, easier to understand.

    For instance you don’t know how many functions you need to call before your actual function with the SetParam method. But passing parameters in the function allows you to assess if you provide enough parameters just by looking at the function declaration or the struct members. In the case where you need to call individual methods to set parameters, you must have documentation.

    Similarly you can put each struct member as a separate parameter in your function but too many parameters become harder to maintain in a single function call after a certain number. Using pointer to a struct in that case is better.

    Think yourself as someone who purchased the DLL from a company. How would you prefer the DLL to be? Which way would be easier, more straightforward to write code on?

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

Sidebar

Related Questions

Here's my scenario - I have an SSIS job that depends on another prior
Here is my code, which takes two version identifiers in the form 1, 5,
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here is the scenario: I'm writing an app that will watch for any changes
Here we go again, the old argument still arises... Would we better have a
Here’s a problem I’ve really been struggling with. I need to merge two sorted
Here's an excerpt from java.text.CharacterIterator documentation: This interface defines a protocol for bidirectional iteration
Here, i have coded to get data from DB. I want to store the
here's what I currently have, unfortunately I cannot seem to figure out how to

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.