Help troubleshoot some code

Hi all,

I've copied this code directly from a tutorial which I can link to you if you can't easily find an answer.

However, when I try to run this code in Visual Studio 15 I receive errors.

Here's the main piece of code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  #include "WinMain.h"

// Additional include files
#ifndef _STRING_H
#include "string.h"
#endif
#ifndef _IOSTREAM_H
#include "iostream.h"
#endif

#if defined (DEBUG) | defined(_DEBUG)
int _tmain(int argc, char* argv[])
{
	UNREFERENCED_PARAMETER(argc);
	UNREFERENCED_PARAMETER(argv);

	//Logger::Log("Starting the program");

	//Run winmain function
	WinMain(HINSTANCE)GetModuleHandle(NULL), 0, 0, SW_SHOW);
}
#endif

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
{
	UNREFERENCED_PARAMETER(hInstance);
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);
	UNREFERENCED_PARAMETER(nCmdShow);

#if defined (DEBUG) | defined(_DEBUG)
	HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);

	//EnableRunTime Memory Leak Checking for Debug Builds.

	//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DP);
	//_CrtSetBreakAlloc(0);
#endif

	//Creat the Engine.
	//Engine* pEngine = new Engine();

	//Kick off the game
	//int result = pEngine->RunLoop();

	//Delete the Engine
	//delete pEngine;

	//return result;

	return 0;
}


Here is the error list:

Severity Code Description Project File Line Suppression State

Error C2447 '{': missing function header (old-style formal list?) DyroEngine2 c:\users\username\desktop\dyroengine2\winmain.cpp line 25

Error (active) type name is not allowed DyroEngine2 c:\Users\username\Desktop\DyroEngine2\WinMain.cpp line 20

Error (active) too few arguments in function call DyroEngine2 c:\Users\username\Desktop\DyroEngine2\WinMain.cpp line 20

Error (active) expected a ';' DyroEngine2 c:\Users\Jamez\Desktop\DyroEngine2\WinMain.cpp line 20

Error (active) expected a declaration DyroEngine2 c:\Users\username\Desktop\DyroEngine2\WinMain.cpp line 25

Error (active) this declaration has no storage class or type specifier DyroEngine2 c:\Users\username\Desktop\DyroEngine2\WinMain.cpp line 32

Error (active) expected a ')' DyroEngine2 c:\Users\username\Desktop\DyroEngine2\WinMain.cpp line 32

Error (active) expected a declaration DyroEngine2 c:\Users\username\Desktop\DyroEngine2\WinMain.cpp line 51

Error (active) expected a declaration DyroEngine2 c:\Users\username\Desktop\DyroEngine2\WinMain.cpp line 52

Error C2275 'HINSTANCE': illegal use of this type as an expression DyroEngine2 c:\users\username\desktop\dyroengine2\winmain.cpp line 20

Error C2146 syntax error: missing ';' before identifier 'GetModuleHandleA' DyroEngine2 c:\users\username\desktop\dyroengine2\winmain.cpp line 20

Error C2059 syntax error: ')' DyroEngine2 c:\users\username\desktop\dyroengine2\winmain.cpp line 20
Those error messages give line numbers, so that should be a big help in looking for the errors.

1) At line 20, you clearly have one more close-parenthesis than you do open-parenthesis. If that's a function call, it's obviously badly formed.

2) You shouldn't have a semicolon at the end of the first line of the function definition.
Last edited on
Topic archived. No new replies allowed.