static PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR), 1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA,
ColorDepth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE,
0, 0, 0, 0
};
Causes an error. Ive no clue why.
D:\Promit\C++\OpenGL\Pong2D\pong2d.c(65) : error C2143: syntax error : missing '';'' before ''type''
This error occurs when pfd is referenced again:
D:\Promit\C++\OpenGL\Pong2D\pong2d.c(83) : error C2065: ''pfd'' : undeclared identifier
I dont know why its complaining. Im pretty sure im initializing pfd with correct number of members, as messy as it is.
Question writing pure C with OGL
I know C++ pretty well, but i decided to try writing real, pure C. Easier said than done...
Initializers must be constant. Looks like you''ve got a variable "ColorDepth" mixed in with the literals.
Try this instead:
Try this instead:
static PIXELFORMATDESCRIPTOR pfd;memset(&pfd,0,sizeof(pfd));pfd.nSize = sizeof(pfd);pfd.nVersion = 1;pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;pfd.iPixelType = PFD_TYPE_RGBA;pfd.cColorBits = ColorDepth;pfd.cDepthBits = 16;pfd.iLayerType = PFD_MAIN_PLANE;
static PIXELFORMATDESCRIPTOR pfd; memset( &pfd, 0, sizeof(PIXELFORMATDESCRIPTOR) ); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = ColorDepth; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE;
D:\Promit\C++\OpenGL\Pong2D\pong2d.c(65) : error C2143: syntax error : missing '';'' before ''type''
D:\Promit\C++\OpenGL\Pong2D\pong2d.c(72) : error C2065: ''pfd'' : undeclared identifier
D:\Promit\C++\OpenGL\Pong2D\pong2d.c(73) : error C2224: left of ''.nSize'' must have struct/union type
D:\Promit\C++\OpenGL\Pong2D\pong2d.c(74) : error C2224: left of ''.nVersion'' must have struct/union type
D:\Promit\C++\OpenGL\Pong2D\pong2d.c(75) : error C2224: left of ''.dwFlags'' must have struct/union type
D:\Promit\C++\OpenGL\Pong2D\pong2d.c(76) : error C2224: left of ''.iPixelType'' must have struct/union type
D:\Promit\C++\OpenGL\Pong2D\pong2d.c(77) : error C2224: left of ''.cColorBits'' must have struct/union type
D:\Promit\C++\OpenGL\Pong2D\pong2d.c(78) : error C2224: left of ''.cDepthBits'' must have struct/union type
D:\Promit\C++\OpenGL\Pong2D\pong2d.c(79) : error C2224: left of ''.iLayerType'' must have struct/union type
I take it that wasnt the effect you were intending, but things got worse, not better.
if it''s not already (which I''m guessing it''s not from those error messages), move the variable to the top of the function...
C likes to have all its variables declared at the top of a function
Don''t you love completely undescriptive error messages?
-noh
C likes to have all its variables declared at the top of a function
Don''t you love completely undescriptive error messages?
-noh
"error C2065: ''pfd'' : undeclared identifier"
This looks like the problem. The rest follow from that. Double check the include headers for the structure definition. Make certain you''ve got the correct header in scope.
"missing '';'' before ''type''"
Did you forget to close the previous statment? Could be a missing semi-colon.
"C likes to have all its variables declared at the top of a function"
All the variables are at the top. ColorDepth isn''t declared in the snippet provided. My guess is it''s a parameter?
This looks like the problem. The rest follow from that. Double check the include headers for the structure definition. Make certain you''ve got the correct header in scope.
"missing '';'' before ''type''"
Did you forget to close the previous statment? Could be a missing semi-colon.
"C likes to have all its variables declared at the top of a function"
All the variables are at the top. ColorDepth isn''t declared in the snippet provided. My guess is it''s a parameter?
quote:Original post by Anonymous Poster
static struct PIXELFORMATDESCRIPTOR pfd;
That''s not needed in this case. The typedef PIXELFORMATDESCRIPTOR is for "struct tagPIXELFORMATDESCRIPTOR".
quote:Original post by Null and Void
That''s not needed in this case. The typedef PIXELFORMATDESCRIPTOR is for "struct tagPIXELFORMATDESCRIPTOR".
I stand corrected. I don''t use windows and thought this could be the reason.
quote:Original post by nohbdy
if it''s not already (which I''m guessing it''s not from those error messages), move the variable to the top of the function...
C likes to have all its variables declared at the top of a function
Don''t you love completely undescriptive error messages?
-noh
Yes that was the reason. I kind of find it useful to declare vars mid-function sometimes. WHen I moved it up top, it was fine.
-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.
Democracy is where you say what you want and do what you''re told.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement