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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:22:57+00:00 2026-06-09T13:22:57+00:00

Possible Duplicate: Name mangling of c++ classes and its member functions? I created a

  • 0

Possible Duplicate:
Name mangling of c++ classes and its member functions?

I created a Visual C++ dll. It is working and i can call my Thrust methods from cuda through this dll in c#.

The only problem is, that i am not able to unmangle the function names. I would like to have the normal names so i would not need to use an Entrypoint with the convention.

Here is my code.
This is my header

//ThrustCH.h
    #pragma once
    enter code here__declspec(dllexport) class ThrustFuncs 
    {
        __declspec(dllexport) static int maxValueThrust(int *data, int N);
        __declspec(dllexport) static double maxValueThrust(double *data, int N);
        __declspec(dllexport) static int* sort(int* data, int N);
        __declspec(dllexport) static double* sort(double* data, int N);
        __declspec(dllexport) static int simple(int N);
    };

This is my cpp

// thrustDLL.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include "thrustH.h"
#include "thrustCH.h"

extern "C" {
    __declspec(dllexport) int ThrustFuncs::maxValueThrust(int *data, int N){
        return thrustH::maxValue(data,N);
    }

    __declspec(dllexport) double ThrustFuncs::maxValueThrust(double *data, int N){
        return thrustH::maxValue(data,N);
    }

    __declspec(dllexport) int* ThrustFuncs::sort(int* data, int N){
        return thrustH::sort(data,N);
    }
    __declspec(dllexport) double* ThrustFuncs::sort(double* data, int N){
        return thrustH::sort(data,N);
    }
    __declspec(dllexport) int ThrustFuncs::simple(int N){
        return N;
    }
}

I tried to use extern “C” and __declspec(dllexport) almost everywhere put i guess I’m doing something wrong. Could you help me please?

  • 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-06-09T13:22:59+00:00Added an answer on June 9, 2026 at 1:22 pm

    It seems you are trying to export C++ functions but want them to have a C name.

    There is no direct way to do that, mainly because it doesn’t make sense.

    C doesn’t have classes (or namespaces for that matter) and those usually are involved in the C++ name mangling. That is, don’t write the functions you intend to export with a C name decoration in a class declaration.

    You can, however, still write C functions (in an extern "C" block) in which you call your C++ functions, methods, or classes.

    Something like:

    class foo
    {
      static int bar(const std::string& str) { return static_cast<int>(str.size()); }
    }
    
    extern "C"
    {
      int bar(const char* str)
      {
        // Call C++ version of the function.
        try
        {
          return foo::bar(str);
        }
        catch (std::exception&)
        {
          // Handle it somehow
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: get name of current PHP script in include file Can an included
Possible Duplicate: Determine original name of variable after its passed to a function. I
Possible Duplicate: How can I get the name of function inside a JavaScript function?
Possible Duplicate: Dynamically retrieving current method's name Obj-C introspection: How can a method reference
Possible Duplicate: Can I use a generated variable name in PHP? Am stuck here!
Possible Duplicate: Can a number used to name a sql column I am trying
Possible Duplicate: Why do multiple-inherited functions with same name but different signatures not get
Possible Duplicate: From the string name of a class, can I get a static
Possible Duplicate: Property Name and need its value Hi, This one should be easy
Possible Duplicate: Storing Smtp from email friendly display name in Web.Config I'm working on

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.