typedef struct

Started by
10 comments, last by Choo Wagga Choo Choo 1 month ago

I get a “SDL_Rect redefinition different basic types” error here is my stubbed out code

#include <iostream>
#include <SDL.h>

using namespace std;

typedef struct {
	Sint16 x, y;
	Uint16 w, h;
}SDL_Rect;

int main()
{
	SDL_Rect rect;
	rect.x = 279;
	rect.y = 438;
	rect.w = 82;
	rect.y = 42;

	return 0;
}
Advertisement

pbivens67 said:
typedef struct { Sint16 x, y; Uint16 w, h; }SDL_Rect;

Probably you should remove this code. Does it compile then?

The struct should be defined by SDL code, probably in SDL.h.
If not, it should be in another header that comes with SDL, and you need to find out which one and include it as well.

I took out the code but I get this error

Severity Code Description Project File Line Suppression State

Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) Project95 C:\Users\Owner\source\repos\Project95\Project95\MSVCRTD.lib(exe_main.obj) 1

I think your program is trying to link to MSVCRTD.lib in the path you provided (C:\users\owner\source\…).

It should be looking in C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\ (or similar)

Your project configuration is probably set as Windows instead of Console.

edit: It's looking for the WinMain signature.

I got my code to work. Is the ampersand point to the address of the rect values

#include <SDL.h>
#include <iostream>

using namespace std;

int main(int argc, char* args[])
{
	SDL_Rect rect;
	rect.x = 279;
	rect.y = 438;
	rect.w = 82;
	rect.h = 42;

	cout << "The values is: " << &rect << endl;

	return 0;
}

I got my code to work YEAH!!!

4.gif

nice video

Thumbnail

found the better one : )

This topic is closed to new replies.

Advertisement