Thread: Unknown C ESP function call error message

  1. #1
    Polar Fuzz
    Join Date
    Oct 2003

    Unknown C ESP function call error message


    I keep getting the following message after completeing a function call and returning to the main subroutiney but bombs before I can choose to exit the program:

    The value of ESP was not properly saved across a function call. This is usually the result of calling a function declared with one calling convention with a function pointer declared with a different
    calling convention.
    ******************* END OF ERROR MSG ****

    Code is simple, error occurs after running the largeNumber function below and after the program has returned. Note: the largeNumber function has not receiving or sending values.

    #include <stdio.h>
    #include <ctype.h>
    char getMenuOption (void);
    void largestNumber (void);
    void diamond (void);
    int main (void)
    	char  enterKey;
    	char  menuOption;
    	    menuOption = getMenuOption();
    		switch (menuOption)
    			case 'D' :  diamond ();
    			case 'L' :  largestNumber();
    			default  :  printf("\n\n***** GOODBYE *****\n");
    		printf("\nPress [Enter] to Continue ");
    		scanf("%2c", &enterKey);
    	while (menuOption != 'Q');
    	return 0;
    void largestNumber (void)
    ...... code .......

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > scanf("%2c", &enterKey);
    This is one instance of where you're going to be overwriting memory you don't own.

    If there are similar mistakes in your other functions, then I'd say that your memory overwrites are trashing the stack, giving you the bogus error messages.

    Best to post a small and complete program which still demonstrates the problem.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get RSSI value, send to sensor, sensor receive package, repackage it?
    By techissue2008 in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-04-2009, 10:13 AM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM