Assuming that I am not using ANY overloaded functions, is there a way I can stop ALL name mangling?

The name says a lot about everything. I know that I can use the extern "C" block to stop the manipulation (although I'm not quite sure where I should put the specified block), but is there a way to disable it for the whole program? And if I do, will it make libraries that are compiled from code easier to use with something like luajit FFI?

EDIT: The question of whether this is supposedly a duplicate is specific to DLLs and the Visual C ++ compiler. I am just asking a general question in C ++.

+4
source share
1 answer

, extern "C" { } ,

extern "C" {
    int foo(int x, int y);
    void bar(const char* cstr); 
}

, , - ++, c- . . GCC toolchain gcc g++.

UPDATE:
extern , ++ ( .cpp), , , c-. .

#include "MyExportAPI.h"
#include <string>

void bar(const char* cstr) {
    std::string s(cstr); // <<< Note!
}
+3

Source: https://habr.com/ru/post/1543407/


All Articles