1

I was playing with a pdb generated by Visual Studio when I saw memcpy in the list of symbols so I used dumpbin to inspect the import table in the executable but there was no reference to memcpy there.

Isn't memcpy a function exported from crt library? If so, why don`t I see it in the output of dumpbin?

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
dev65
  • 1,440
  • 10
  • 25

1 Answers1

3

memcpy is often treated as an intrinsic, especially when copying small items, and thus is compiled entirely as inline code.

Try copying something larger. Then you might see it in the import table.

Paul Sanders
  • 24,133
  • 4
  • 26
  • 48
  • 1
    this is really !! I tried with some mega bytes and it's now imported from VCRUNTIME140.dll , if you don't mind can I ask you : will memcpy always compiled as inline when I use /MT to build static executable as I noticed that when I use c++ std functions I get some winapi that they are wrappers for in the import table but not the situation with memcpy it doesn't depend on any winapi function – dev65 Jun 13 '18 at 23:23
  • I doubt the compiler cares about that flag when it's deciding what code to emit for any particular invocation of `memcpy ()` since (as I'm sure you know) all it does is control whether the program is linked statically or dynamically. You can experiment further [here](https://godbolt.org) if you want to check it out yourself. And you can accept my answer if you want to reward me for sharing - that's the usual practise here. Thx. – Paul Sanders Jun 14 '18 at 04:29
  • @dev65 I don't think you have the rep yet to vote but you can [accept it](https://stackoverflow.com/help/someone-answers). (I am _shameless_ :) – Paul Sanders Jun 14 '18 at 10:09