#Aliasing `extern` functions

8 messages · Page 1 of 1 (latest)

lean harness
#

Hi,

I have a C library that has generated function names. It's not really practical to change them all at the same time, so I want to use aliasing. I'm using gcc and know about the __attribute(alias("name"))___ but the problem is that the functions are in another translation unit.

Is it possible to alias extern function names without redefining them everywhere? Right now I do it like this:

extern "C" {
  extern void w2c_f337(u32, u32, u32);
};

void my_name(u32 a, u32 b, u32 c) {
  w2c_f337(a, b, c);
} 

I want to avoid this boiler plate in a clean way.

Any tips?

pastel zephyrBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.

west shoal
#

is it possible that you could put something like this in a header file

#
extern "C" {
  extern void w2c_f337(u32, u32, u32);
};
inline auto &my_name = w2c_f337;
#

specifically do you just need these aliased at the call sites or do you need the aliases exposed for dynamic linking

lean harness
#

I just want them aliased at the call site so I think the aboven solution might be the correct one

#

I'm also experimenting with

void get_text(u32, u32) asm("w2c_f167");

but I'm scared that I don't know what I'm doing xD

pastel zephyrBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.