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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:34:03+00:00 2026-05-15T21:34:03+00:00

We have a situation where we use a set of third-party unmanaged C++ libraries

  • 0

We have a situation where we use a set of third-party unmanaged C++ libraries in our C# (WPF) application, but we also use a subset of their include libraries to build our own unmanaged libraries to use in our application.

These libraries produce metadata, which is stored in a database. However, we must replicate some constants related to this metadata in our C# code, in order to use the metadata.

There is a potential issue, then, if some of these constants change between versions. Is there a clean way for the C# application to use the constants defined in the C++ include files?

Thanks,
wTs

  • 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-15T21:34:04+00:00Added an answer on May 15, 2026 at 9:34 pm

    I have a solution that you may not consider terribly “clean” but which will work. The problem is that using either an enum or #define preprocessor directives will discard the symbolic name you’re using for the constant (like ERR_OUT_OF_MEMORY will really just be some integer).

    In the C++ code, you could define a function which takes in a string name of the symbol and returns its value. You could use an std::map, then add pairs such as std::pair(“ERR_OUT_OF_MEMORY”, ERR_OUT_OF_MEMORY) Then you can call that function from the DLL using DllImportAttribute which allows unmanaged interop in .NET. Unfortunately this requires going through and string-ifying the constants, but the advantage is that if these constants change, it will be automatic.

    Another solution is to write a simple script that goes through preprocessor #defines and creates a gigantic .NET class with a bunch of static constants with the same name. This actually wouldn’t be that hard considering the simplicity of the preprocessor (should only take a few lines of Perl)

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

Sidebar

Related Questions

We have a situation where we use JSR-330 based injections to configure our stand-alone
I have a situation where I want to use permissions on database objects, but
I have the situation where i use GIS software which stores the information about
We have a situation where we want to use filter for URL's containing some
i have a situation where i need to use GPS technique. i need to
In my view, if I have a situation where I need to use a
Situation:- In my code I have to use the LWUIT Component object for the
My coworker and I have encountered a nasty situation where we have to use
I have following situation: I use Struts2 as MVC cobtroller I use Spring as
Working with a relatively large data set I have a situation where I need

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.