On Sun, Apr 1, 2018 at 4:34 AM, Jason Vas Dias <jason.vas.d...@gmail.com> wrote: > In C++ however, it does not compile : > > $ g++ -g -std=gnu++11 -x c++ -c t.c > t.c:5:8: error: 'void bar()' aliased to undefined symbol 'foo' > void bar(void); > ^ > > Even though, if I compile the object with the declaration > of bar() commented out , I can see C++ is not mangling > the name "foo" :
gcc manual says the follwing about the alias attribute: "In C++, the mangled name for the target must be used." so with the following modification your example compiles: static inline __attribute__((always_inline,alias("_ZL3foov"))) void bar(void); -- Thanks. -- Max