Overriding C library functions, calling original

后端 未结 4 1258
野性不改
野性不改 2020-12-03 11:00

I am a bit puzzled on how and why this code works as it does. I have not actually encountered this in any project I\'ve worked on, and I have not even thought of doing it my

4条回答
  •  臣服心动
    2020-12-03 11:43

    The linker will search the files you provide on the command line first for symbols, before it searches in libraries. This means that as soon as it sees that getline has been defined, it will no longer look for another getline symbol. This is how linkers works on all platforms.

    This of course has implications for your fifth point, in that there is no possibility to call the "original" getline, as your function is the original from the point of view of the linker.

    For the fifth point, you may want to look at e.g. this old answer.

提交回复
热议问题