2 ms·
More or less. I don’t think declaring your own memcpy ‘inline’ will get you all the benefits of using the ‘real’ one. If you want your compiler to know what me
by Someone 4y ago
More or less. I don’t think declaring your own memcpy ‘inline’ will get you all the benefits of using the ‘real’ one.
If you want your compiler to know what memcpy does, so that, for example, it can compile it as an inlined “load register, store register” instruction pair _if_ it knows it’s copying 8 bytes, you have to #include<string.h> (with the angle brackets; #include "string.h" won’t do)
So, if you want optimal performance, you can’t do without the compiler header.
You’re still free to link with your own implementation of memcpy, of course, but don’t expect it to be called in all places where the source code contains calls to it.
- tsimionescu 4y agoI think in this case doing #import<string.h> but then not linking to a libc should work, as long as you're only using the function your compiler implements with intrinsics.