name-mangling

Preventing mangled names in Ada DLL

北城余情 提交于 2019-12-12 13:10:45
问题 Is there a simple way to prevent Ada names from getting mangled when creating an Ada DLL? Here is my .adb code with Ada.Text_IO; package body testDLL is procedure Print_Call is begin Ada.Text_IO.Put_Line("Hello World"); end Print_Call; function Add_Nums(A,B : in Integer) return Integer is begin return A + B; end Add_Nums; end testDLL; my .ads package testDLL is procedure Print_Call; pragma export (dll, Print_Call, "Print_Call"); function Add_Nums(A,B : in Integer) return Integer; pragma

Forcing name mangling in x64 DLL

北慕城南 提交于 2019-12-12 04:31:10
问题 I am porting a 32-bit application to 64-bit. The application supports plugins which are DLLs. Unfortunately, one of the mandatory functions each plugin needs to have is called FreeLibrary which of course conflicts with the kernel32 API of the same name. The reason why my plugin API uses the FreeLibrary name is that the application originated on a different platform where FreeLibrary doesn't clash with any OS APIs. However, even on 32-bit Windows using FreeLibrary is not a problem because 32

extern const linkage specification being seemingly ignored by G++

偶尔善良 提交于 2019-12-11 11:08:27
问题 I have a situation building a C codebase with a C++ compiler that parallels this: lib.h extern int const values[2] = {1, 2}; lib.c #include "lib.h" main.c #include <iostream> extern int const values[2]; int main() { std::cout << values[0] << ":" << values[1] << std::endl; } I had to add the extern because of something pointed out in the C++03 Standard Annex C Compatibility C.1.2 Clause 3. (Compiling with -fpermissive will sweep this under the rug.) Incidentally the difference it makes in how

c++filt not aggressive enough for some of the mangled names in PTX files

大兔子大兔子 提交于 2019-12-11 04:14:42
问题 I'm filtering my compiled PTX through c++filt, but it only demangles some of the names/labels and leaves some as-is. For example, this: func (.param .b32 func_retval0) _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c6__shflEiii( .param .b32 _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c6__shflEiii_param_0, .param .b32 _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c6__shflEiii_param_1, .param .b32 _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c6__shflEiii_param_2 ) is demangled as this: .func (

Compiler error for conflicting variable declarations: “conflicts with new declaration with 'C' linkage”

独自空忆成欢 提交于 2019-12-11 03:03:00
问题 I ran across some legacy code that's failing to build on a newer compiler. The boiled down example: int x; extern "C" { int x }; // conflicts with C++ linkage above // note: without the braces it would've been equivalent to: // extern "C" { extern int x; } // // for reference, see the notes section here: // http://en.cppreference.com/w/cpp/language/language_linkage#notes The older compilers weren't flagging it, but both gcc (as of 4.1.2) and clang flag it. Clang's output: error: declaration

Name mangling in CUDA and C++

≡放荡痞女 提交于 2019-12-11 02:46:41
问题 My C++ project main.cpp , compiled with pgcpp from PGI, calls a function cuda() containing CUDA code in a separate file cuda.cu , compiled with nvcc . Unless I wrap the cuda() function with extern "C" in the function declaration and the common header file, I get linking errors (undefined references). Without extern "C" (symbol name mismatch => undefined reference): $ nm main.o | grep -y cuda U cuda__FPfPiT2iN32 $ nm cuda.o | grep -y cuda T _Z13cudaPfPiS0_iS0_S0_S0_ With extern "C" (symbol

Is function parameter constness mismatch allowed?

余生颓废 提交于 2019-12-10 18:37:28
问题 Regarding using const function parameters I've heard that on some OS X systems the constness of a parameter is mangled into the function signature. For example, if one would have the following declaration in an interface header file: int f(int argument); but if one would only implement this function: int f(int const argument); then this might lead to a linking failures on OS X (but not on Linux) because the OS X way to mangle C++ function signatures includes the constness of the parameters.

Assuming I don't use ANY overloaded functions, is there a way I can stop ALL name mangling? [duplicate]

陌路散爱 提交于 2019-12-10 17:26:42
问题 This question already has answers here : Is there a way to suppress c++ name mangling? (3 answers) Closed 5 years ago . The title pretty much says it all. I know I can use and extern "C" block to stop mangling (although I'm not entirely sure where I should put said block) but is there a way that I can disable it for the whole program? And if I do, will that make the libraries that are compiled from the code easier to use with something like luajit's FFI? EDIT: The question that this is

private public protected access specifiers in python

时光毁灭记忆、已成空白 提交于 2019-12-10 10:11:46
问题 Can we simulate private and protected access specifiers in python? Name Mangling eg: __var=10 can simulate private but its viable to be accessed outside easily via the object. object._className__var So is there a way we could simulate or does python a solution directly which I am not aware of? 回答1: Python does not have mandatory access control like some other languages you may be used to. The philosophy of the language is "We are all consenting adults". By convention, private attributes are

64bit name mangling for c++

▼魔方 西西 提交于 2019-12-08 18:12:06
问题 I have a bit of code which has the following line #pragma comment(linker, "/include:_test@12") The project which uses this code works fine when I compile the code using C++ Visual Studio 2010 with configuration type 32bit (I am also on a 32 bit windows machine). I get a link error when I change the machine to 64bit and use x64 configuration which compiling with C++ Visual Studio 2010. Is C++ name mangling different for 32bit vs 64bit? If so, where can I find the 64bit C++ name mangling