0

Hi all, This is a question about some weird behaviour I found while building a DLL.

#define EXTERNC  extern "c"
#define APIEXPORTS  __declspec(dllexport)
#define STDCALL __stdcall
EXTERNC APIEXPORTS STDCALL InvokeCommand(int* c, uint8_t* buff, uint16_t opcode, double* args)

Size of Args = 3*(sizeof(pointer 32bit)) + sizeof(uint16_t) = 14. BUT: Looking at the dumpbin output from this export gives the following decorated name:

_InvokeCommand@16

According to MSDN (I am compiling in VS cpp):

"Leading underscore (_) and a trailing at sign (@) followed by the number of bytes in the parameter list in decimal"

but then the name should have been ...@14 not 16. Each of the three pointers being 4 bytes, and the uint16_t being two. Can anyone explain this behaviour?

EDIT: InvokeMessageProcess(int*, uint8_t*, int8_t*); gave the correct behaviour of _InvokeMessageProcess@12 !! Seems inconsistent!

sbail95
  • 198
  • 8
  • 3
    My bet would be alignment. 12 and 16 are aligned on 4 bytes. 14 is not. – kichik Oct 20 '16 at 18:56
  • 4
    The size of each parameter must be a multiple of 4 bytes, for alignment purposes. If the formal parameter is not an exact multiple of 4 bytes, then it is rounded up to the next multiple of 4 bytes. – Raymond Chen Oct 20 '16 at 19:06
  • http://stackoverflow.com/questions/1255775/default-argument-promotions-in-c-function-calls – Hans Passant Oct 20 '16 at 19:24

0 Answers0