So I'm currently stuck trying to get the windows api to show up (language is c++), when I try to run the program I get the following errors. (though I am getting now error showing up in regards to the red underline). I am currently using visual studio community as my IDE.
"unresolved external symbol _main reference in function "int _cdel invoke(main(void))"
"1 resolved externals"
I've already checked online, and tried it both as a win 32 console program and a win 32 project (which some have listed as a way to resolve the program.) However no results. I have no idea what the error could be. (also for reference I am using the following tutorial as a starting base https://www.youtube.com/watch?v=012pFrYE5_k, but am not using the open GL library as all I am trying to accomplish is make a very simplified template of a win32 window). Any Idea's?
Code: main.h
#pragma once
#pragma once
#include<Windows.h>
#include<tchar.h>
#include<iostream>
#define WINDOW_WIDTH = 800 //remember to leave off the ; at the end of define sets(currently not being used
#define WINDOW_HEIGHT = 600
HWND hWnd;
Code: main.cpp
#include "main.h" //remember <> means library, "" means within your project.
// long results, CALL BACK, windows procedure, basically the basics of what to do. UINT (unsigned INT)
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CREATE:
break;
case WM_DESTROY:
case WM_QUIT:
case WM_CLOSE:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
/*
remember that this is a run time instance, and is in essence the same as Main (char[args]) {}
returning 0 ends the operation of the win32 library.
*/
int WINAPI winMain(HINSTANCE hInstance, HINSTANCE hPrevious, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wc; //default instance for the scope of the window (new window named WC for WINDOW CLASS)
MSG msg;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); //default background color, set to stock light gray
wc.hCursor = LoadCursor(hInstance, IDC_ARROW); //default cursor
wc.hInstance = hInstance;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = _T("NAME");
wc.lpszMenuName = NULL;
wc.style = CS_VREDRAW | CS_HREDRAW; //windows style in bit form, 0X00 hex if you were to print them
if (!RegisterClass(&wc)) //pointer the to the window, if it doesn't exist call this simple error handle
{
MessageBox(NULL, _T("error: cannot reg window class"), _T("error"), MB_OK);
return 0; // kills
}
hWnd = CreateWindow(L"NAME", //reference of the object already defined as wc
L"Window Title", //title
WS_OVERLAPPEDWINDOW, //basic window style
0, //x start,
0, //y start,
800,
600, //set all the dimensions to default value
NULL, //no parent window
NULL, //no menu
hInstance,
NULL);
if (!hWnd)
{
MessageBox(NULL, L"ERROR: cannot create window", L"ERROR!", MB_OK);
return 0;
}
while (1)
{
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
if (GetMessage(&msg, NULL, 0, 0))
{
break;
}
}
DispatchMessage(&msg);
TranslateMessage(&msg);
}
return(int)msg.wParam;
}