name-mangling

Can I ungarble GCC's RTTI names?

此生再无相见时 提交于 2019-12-19 07:23:44
问题 Using gcc, when I ask for an object/variable's type using typeid, I get a different result from the type_info::name method from what I'd expect to get on Windows. I Googled around a bit, and found out that RTTI names are implementation-specific. Problem is, I want to get a type's name as it would be returned on Windows. Is there an easy way to do this? 回答1: If it's what you're asking, there is no compiler switch that would make gcc behave like msvc regarding the name returned by type_info:

Dynamic Loading Without extern “C”

喜欢而已 提交于 2019-12-19 03:15:37
问题 I'd like to use libdl to dynamically load C++ in general. The problem is identifying symbols at runtime that have been name mangled. As described here, one solution is to remove name mangling by using extern "C". http://www.tldp.org/HOWTO/C++-dlopen/theproblem.html This solution has the drawback of limiting dynamically loaded resources to C style interfaces. Dynamically loaded functions cannot, for instance, be overloaded functions. What is a good way to overcome this limitation? One possible

View Compiler Mangled Names in C++

不打扰是莪最后的温柔 提交于 2019-12-19 02:03:14
问题 How do I view the compiler-generated mangled names for overloaded functions in C++? I'm using VC9 but answers for other compilers are welcome too. Edit: I find all the answers useful here. Accepting the one I liked best. 回答1: You could look in the map file. Assuming you have map file generation turned on. 回答2: You can see the decorated function names by using Dependency Walker. Open any DLL\EXE in dependency walker and in right pane you can see a list of decorated function names. 回答3: Since

Is there a way to suppress c++ name mangling?

扶醉桌前 提交于 2019-12-18 04:25:09
问题 I have a DLL that is written in C++ and I want to suppress the name mangling for a few exported methods. The methods are global and are not members of any class. Is there a way to achieve this? BTW: I'm using VS2008. 回答1: "bradtgmurray" is right, but for Visual C++ compilers, you need to explicitly export your function anyway. But using a .DEF file as proposed by "Serge - appTranslator" is the wrong way to do it. What is the universal way to export symbols on Visual C++ ? Using the declspec

stdcall name mangling using extern c and dllexport vs module definitions (msvc++)

强颜欢笑 提交于 2019-12-17 19:33:42
问题 I was trying to export a simple test function for a dll to work with an application (fyi: mIRC) that specifies the calling convention as: int __stdcall test_func(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause) Now, to call this from the application, I'd be using test_func but I have noticed due to name mangling it is not as simple as I'd thought. Through similar topics here I have come to the understanding that using extern "C" in combination with __declspec(dllexport)

questions about name mangling in C++

旧巷老猫 提交于 2019-12-17 06:35:27
问题 I am trying to learn and understand name mangling in C++. Here are some questions: (1) From devx When a global function is overloaded, the generated mangled name for each overloaded version is unique. Name mangling is also applied to variables. Thus, a local variable and a global variable with the same user-given name still get distinct mangled names. Are there other examples that are using name mangling, besides overloading functions and same-name global and local variables ? (2) From Wiki

How do I stop name-mangling of my DLL's exported function?

帅比萌擦擦* 提交于 2019-12-17 04:30:44
问题 I'm trying to create a DLL that exports a function called "GetName". I'd like other code to be able to call this function without having to know the mangled function name. My header file looks like this: #ifdef __cplusplus #define EXPORT extern "C" __declspec (dllexport) #else #define EXPORT __declspec (dllexport) #endif EXPORT TCHAR * CALLBACK GetName(); My code looks like this: #include <windows.h> #include "PluginOne.h" int WINAPI DllMain (HINSTANCE hInstance, DWORD fdwReason, PVOID

What is name mangling, and how does it work?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 03:36:09
问题 Please explain what is name mangling, how it works, what problem it solves, and in which contexts and languages is used. Name mangling strategies (e.g. what name is chosen by the compiler and why) a plus. 回答1: In the programming language of your choice, if an identifier is exported from a separately compiled unit, it needs a name by which it is known at link time. Name mangling solves the problem of overloaded identifiers in programming languages. (An identifier is "overloaded" if the same

How to access private variable of Python module from class

半城伤御伤魂 提交于 2019-12-14 03:59:54
问题 In Python 3, prefixing a class variable makes it private my mangling the name within the class. How do I access a module variable within a class? For example, the following two ways do not work: __a = 3 class B: def __init__(self): self.a = __a b = B() results in: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in __init__ NameError: name '_B__a' is not defined Using global does not help either: __a = 3 class B: def __init__(self): global __a

Wrapping a C lib with extern “C” except an internal C++ include

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 20:18:16
问题 I have a C library that I need to use in a C++ code, so I need to wrap the whole lib with an extern "C" block. The problem is that the library seems to include a C++ compiled code, so wrapping the whole lib would also wrap that C++ header. Inside lib.h I only include all the internal headers I want to expose, something like this: #ifndef LIB_H #define LIB_H #include "lib_foo.h" #include "lib_bar.h" #include "lib_baz.h" #endif So the client will only need to include lib.h to use the lib. In my