Results 1 to 7 of 7

Thread: Run-Time Check Failure #0

  1. #1
    Join Date
    Jun 2011
    Posts
    56

    Run-Time Check Failure #0

    Hi I have developed very small program for calculation, and in that I have included my personal DLL files that I have created. The DLL files contains the code

    Code:
    extern "A" declspec(dllexport)
    int fact(int n)
    {
    	double j, fac;
    	for(j = 2, fac = 1; j <= n; j++)
    		fac*=j;
    	return fac;
    }
    And I am calling those DLL files from my program and while compiling the code I am getting the error like “Run-Time Check Failure #0 The value of ESP was not properly , any suggestion?

  2. #2
    Join Date
    May 2009
    Posts
    637

    Re: Run-Time Check Failure #0

    This is typically occur while you have the incorrect calling convention on functions, I mean to say there might be some spelling mistake in the your programs thus you’re having this problems, and this is generally occurs due to the lines declspec (dLL---) or this is also possible that you have build the DLL next to the incorrect runtime libraries. So my recommendation is same as you should first of all check all the things in the coding like is properly written.

  3. #3
    Join Date
    May 2009
    Posts
    511

    Re: Run-Time Check Failure #0

    The DLL that you have declared is might be having a number of a dissimilar calling convention than the function pointer, and in C++ let me tell you that there are two calling conventions and they are cdecl and stdcall, I would suggest you that you must have to declare your function pointer to be equivalent as the correct calling convention as your DLL function.

  4. #4
    Join Date
    Jun 2011
    Posts
    56

    Re: Run-Time Check Failure #0

    OK let me tell you about the other code also which actually causing these error, see actually I am using WINAPI in the program and the program is actually to calculate the factorial of the given number, and in that in the main function the line i = fact(5); is causing the actual error, even though there is error, but program calculate the value perfectly.

  5. #5
    Join Date
    May 2009
    Posts
    543

    Re: Run-Time Check Failure #0

    Yeah I got your problem, the error is not actually there I would say as you have mentioned your developed DLL, there is the Problem because as far as I know C++ has only two calling convention that is mentioned by the above user, and It seems you have used the incorrect one in your DLL, because as far as I know the WINAPI contains stdcall, whereas In your DLL you had used cdecl function, so first of all change that and then see whether the problem happens or not.

  6. #6
    Join Date
    Jun 2011
    Posts
    56

    Re: Run-Time Check Failure #0

    Hey thanks for giving the suggestion as according to your mentioned one i have changed those values in the programs but after that the first error was solved but I got some another error like

    warning C4518: 'int ' : storage-class or type specifier(s) unexpected here

    warning C4230: anachronism used : modifiers/qualifiers interspersed

    and it says not able to load the function fact, now what can I do next?

  7. #7
    Join Date
    May 2009
    Posts
    539

    Re: Run-Time Check Failure #0

    Answer6- Follow this code for finding the factorial of the program

    Code:
    extern "A" int declspec(dllexport) stdcall
    fact(int n)
    {
    	int i, fac;
    	for(i = 2, fac = 1; i <= n; i++)
    		fac*=i;
    	return fac;
    }
    After that you can call this DLL through actual name of the DLL not the one that you have mentioned, and to see that name you can use the Dependency Walker utility.

Similar Threads

  1. Windows Restore Failure caused due Virus or Hardware Failure
    By Thedevotee in forum Operating Systems
    Replies: 2
    Last Post: 11-04-2012, 05:21 PM
  2. Replies: 4
    Last Post: 20-03-2012, 10:39 PM
  3. Multiple Wireless controller failure at one time
    By Ga.One in forum Networking & Security
    Replies: 9
    Last Post: 31-12-2011, 05:58 PM
  4. Replies: 4
    Last Post: 23-03-2011, 03:12 AM
  5. How to check the awstats time zone
    By Gefry in forum Windows Software
    Replies: 3
    Last Post: 07-08-2009, 10:39 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,979,483.67623 seconds with 17 queries