Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. DLL Calling convention problem

DLL Calling convention problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpai-modelsdebuggingjson
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bert Tuyt
    wrote on last edited by
    #1

    I started programming a "simple" DLL with dynamic linking from the main application via LoadLibrary , GetProcAddress (and the rest). Somewhere I make a trivial fault, which so far is difficult to correct. Everything goes well, but when the function is exected, i get the next message. Debug Error, File chkesp.c, line 41 The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. This should give a clue, but it did not help me so far. To my understaning both my application and dll are compiled/linked with __cdecl as standard, so I'm lost now (but hope not for that long) Bert....

    N C 2 Replies Last reply
    0
    • B Bert Tuyt

      I started programming a "simple" DLL with dynamic linking from the main application via LoadLibrary , GetProcAddress (and the rest). Somewhere I make a trivial fault, which so far is difficult to correct. Everything goes well, but when the function is exected, i get the next message. Debug Error, File chkesp.c, line 41 The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. This should give a clue, but it did not help me so far. To my understaning both my application and dll are compiled/linked with __cdecl as standard, so I'm lost now (but hope not for that long) Bert....

      N Offline
      N Offline
      Neville Franks
      wrote on last edited by
      #2

      Have you tried following the function call through in the Debugger. A reasonable knowlodge of assembler would help here. Do you really need to dynamically load the DLL with LoadLibrary() and if so why? If it is a) because you don't want to waiste time loading until it is required, or b) you don't know if it exists, then using /DELAYLOAD with an SEH exception handler is a much better way to go. See: MSJ, December 1998 Win32 Q&A. http://www.microsoft.com/msj/1298/win32/win321298.aspx[^]for a good article on /DELAYLOAD. Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com

      1 Reply Last reply
      0
      • B Bert Tuyt

        I started programming a "simple" DLL with dynamic linking from the main application via LoadLibrary , GetProcAddress (and the rest). Somewhere I make a trivial fault, which so far is difficult to correct. Everything goes well, but when the function is exected, i get the next message. Debug Error, File chkesp.c, line 41 The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. This should give a clue, but it did not help me so far. To my understaning both my application and dll are compiled/linked with __cdecl as standard, so I'm lost now (but hope not for that long) Bert....

        C Offline
        C Offline
        Chris Losinger
        wrote on last edited by
        #3

        assuming you're exporting C functions (not C++ stuff) it might help to add ' extern "C" ' to the function declarations : DLL's header: extern "C" WINAPI void MyFunc(...); DLL's implementation: #include "DLLs header.h" ... void WINAPI MyFunc(...) { } -c

        Chris Losinger
        Smaller Animals Software

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups