最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - MSVC equivalent of GCCClang `int f() asm("g")`? - Stack Overflow

programmeradmin0浏览0评论

On Clang and GCC (and GCC-like compilers), you can use "asm labels" on functions and variables to set their mangled symbol name, like this:

int f() asm("g");
int f() { return 42; }

int x asm("y") = 42;

This syntax doesn't work on MSVC (Visual Studio). Does Microsoft support any C or C++ source-level syntax for this kind of thing? Note that in this simple case it's possible to just write the name g in the source code anyway, like this:

extern "C" int g();
int g() { return 42; }

but I'm looking for a way that mimics GCC/Clang's approach — specifically to decouple the C++-source-code name f from the object-file mangling g.

发布评论

评论列表(0)

  1. 暂无评论