Renaming characters at compile time without changing code on a cross-platform path

When creating a static object, can you rename characters at compile time (without changing the code) on a cross-platform path? I recently recommended objcopy, but Linux is not the only target platform on which it should also run on a Mac. I am compiling using gcc, so I was hoping there was a gcc option.

I have heard about .def files, but this may have been misleading, as the information about them that I found seems to be for windows.

Edit: I am trying to change the name of the C and Fortran functions, in particular, having previously waited for them with the word "wrap" to avoid character conflicts during the link.

+4
source share
2 answers

Is it possible to rename characters at compile time

You may be able to achieve this with a preprocessor:

gcc -c foo.c -Dfoo=foo_renamed 
+4
source

You can use the gcc alias attribute to make multiple characters pointing to the same function.

 void name1() __attribute__((alias ("name2"))); 

I'm not sure if the alias attribute works for other types of characters (like variables).

+2
source

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


All Articles