Cry about...
MS-Windows Troubleshooting


error C2055: expected formal parameter list, not a type list


These notes have kindly been provided by Sujith Joseph, in India:

Symptom:

The error message:

PetzoldBookProjects\HelloMsg\HelloMsg.c(15) : error C2055: expected formal parameter list, not a type list
Error executing cl.exe.

On compiling the following code:

#include <assert.h>

const TCHAR szOperation[] = _T("open");
const TCHAR szAddress[] = _T("www.cryer.co.uk");
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR lpCmd, int nShow)
{
  HINSTANCE hRslt = ShellExecute(NULL, szOperation, szAddress, NULL, NULL, SW_SHOWNORMAL);
  assert( hRslt > (HINSTANCE) HINSTANCE_ERROR);
  return 0;
}

The line on which the error was indicated is highlighted in bold.

Solution

The second parameter of WinMain defined only the type HINSTANCE of the parameter. Declaring both the type and identifier of the second parameter as below got rid of the error:

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hprevInst, LPSTR lpCmd, int nShow)
{
  ...



About the author: is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.