Thread: Calling DLL from C "too few arguments to call function"

  1. #1
    Registered User
    Join Date
    Sep 2019

    Calling DLL from C "too few arguments to call function"

    I have a dll written in C and a C program to call it. The C program gives a compile error "too few arguments to call function" but the function it's calling does not have any arguments.

    The dll (SxSv.dll):

    #define EXPORT __declspec(dllexport)
    EXPORT int SSV ();
    __declspec(dllexport) int __stdcall SSXV()
    int n = 0;
    while(n < 500000){
    n += 1;
    return n;
    The C program to call the dll (SxSv.c):

    #include "SxSv.h"
    int loadDLL( )
    int status = 0;
    TestFunc _TestFunc;
    HINSTANCE testLibrary = LoadLibrary("SxSv.dll");
    if (testLibrary)
    _TestFunc = (TestFunc)GetProcAddress(testLibrary, "SSXV");
    if (_TestFunc)
    status = _TestFunc(); // THIS IS THE LINE WITH THE ERROR
    return status;

    The wrapper's header file (SxSv.h):

    #ifndef DLLHANDLER_C_
    #define DLLHANDLER_C_
    #include <windows.h>
    #include <winbase.h>
    #include <windef.h>
    #include <stdio.h>
    typedef int (*TestFunc)(int);
    int loadDLL( void );
    The exported function SSXV() takes no arguments, so why does the line status = _TestFunc(); report "too few arguments" when I compile the C program to call the dll?


  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > typedef int (*TestFunc)(int);
    This is what erroneously gives your function arguments.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2019
    Thanks for the tip. I changed it to typedef int (*TestFunc)(void); and now it works.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 10-13-2012, 01:47 PM
  2. Replies: 3
    Last Post: 03-31-2010, 04:28 AM
  3. Replies: 2
    Last Post: 02-27-2009, 12:46 PM
  4. Function Arguments separated by pipe "|"
    By kendallte in forum C++ Programming
    Replies: 3
    Last Post: 09-03-2008, 03:04 PM
  5. Error: "illegal call of non-static member function"
    By Helix in forum Windows Programming
    Replies: 4
    Last Post: 12-31-2003, 10:01 PM

Tags for this Thread