Click here to Skip to main content
15,889,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Failure #0 is, apparently, "usually the result of calling a function declared with one calling convention with a function pointer declared with a different calling convention".

"Usually"? Does anyone have any idea what else may cause this "unusally"?

When I run my Windows console app in debug mode it always breaks at the same point - at the closing brace of this function:

void threadDelay(int nTicks)
{
Sleep((DWORD)(nTicks * TIME_PER_TICK));
}

So I'm not sure if this is pointing at Sleep() or threadDelay() as the offending function, assuming the failure is a result of the "usual" reason.

threadDelay() is called, eventually, from a function run as a thread started by beginthreadex() which is therefore declared as _stdcall. I have assumed, perhaps wrongly, that the _stdcall requirement of functions started by beginthreadex() doesn't have to be rippled down into any function they call.

The app is compiled with /Gd (_cdecl) for x86 using the multi-threaded DLL run-time libraries. It comprises a number of static libraries and DLLs.
Posted
Comments
CPallini 16-Jul-15 4:10am    
Could you please post more code (e.g. the relevant calls)?
Gordon Smith 16-Jul-15 5:14am    
It's a fairly large project so posting it isn't feasible. Not sure what else to post.

The .h file has:

extern void threadDelay(int nTicks);

threadDelay() source is in original post. It's in a .cpp file if that's of interest.

The thread / task is declared as __stdcall to match beginthreadex(). It makes a series of calls to sprintf() and the resulting string is transmitted from a serial port. Transmission is regulated by threadDelay(10) calls, ensuring a 10 ms delay between messages.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900