directdraw memset() problem

Started by
7 comments, last by liquid_ice_programmer 20 years, 11 months ago
i am getting these errors: Compiling... DD.cpp C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(28) : error C2501: ''memset'' : missing storage-class or type specifiers C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(28) : error C2373: ''memset'' : redefinition; different type modifiers c:\program files\microsoft visual studio\vc98\include\string.h(103) : see declaration of ''memset'' C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(28) : error C2078: too many initializers C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(31) : error C2143: syntax error : missing '';'' before ''.'' C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(31) : error C2501: ''ddsd'' : missing storage-class or type specifiers C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(31) : error C2371: ''ddsd'' : redefinition; different basic types C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(22) : see declaration of ''ddsd'' C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(31) : error C2143: syntax error : missing '';'' before ''.'' C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(32) : error C2143: syntax error : missing '';'' before ''.'' C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(32) : error C2501: ''ddsd'' : missing storage-class or type specifiers C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(32) : error C2371: ''ddsd'' : redefinition; different basic types C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(22) : see declaration of ''ddsd'' C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(32) : error C2143: syntax error : missing '';'' before ''.'' C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(33) : error C2143: syntax error : missing '';'' before ''.'' C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(33) : error C2501: ''ddsd'' : missing storage-class or type specifiers C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(33) : error C2371: ''ddsd'' : redefinition; different basic types C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(22) : see declaration of ''ddsd'' C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(33) : error C2143: syntax error : missing '';'' before ''.'' C:\WINDOWS\Desktop\C++ Folder\General Windows\DD\DD.cpp(188) : warning C4508: ''CreateDirectDrawSurface'' : function should return a value; ''void'' return type assumed Error executing cl.exe. DD.exe - 15 error(s), 1 warning(s) and this is where aree therros seem to be: // Include Files #include <windows.h> #include <string.h> #include <ddraw.h> #include <ddrawex.h> //Clearing Memory memset(&ddsd,0,sizeof(ddsd)); //CreateDirectDrawDesc ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; can someone please help me
Advertisement
You should be sending sizeof() the variable type not the name of your variable. So it should be whatever variable type ''ddsd'' is, for example, sizeof(int) etc. That should alleviate some of your errors.

Somebody correct me if I am wrong.
You''re wrong. That''s perfectly legal use of the sizeof operator.

If I had to guess, I''d say it was code in the source file before the code you posted. Things like forgetting a semi-colon or unmatched braces can trickle down to following statements.

Um, that code you posted... is it inside a function in your source file, or just plastered in the file right after the includes (as you''ve posted it)?




I tried to use DDSURFACEDESC2 in sizeof() but still got same errors. That piece of code in not in a function and i have and my seimcolons and stuff like that right i looked. Does anything have a idea?
EDIT: it's not in a fuction, and yet you expect it to execute? Hmm... gosh, I think I see the problem.

How appropriate. You fight like a cow.

[edited by - sneftel on May 4, 2003 3:43:41 PM]
I am read Tricks of the windows game programming and it does not have any of this in a fuction:

//Clearing Memory

memset(&ddsd,0,sizeof(ddsd));

//CreateDirectDrawDesc
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

so does anyone else no what is wrong.

[edited by - liquid_ice_programmer on May 4, 2003 4:18:42 PM]
I can tell you 100% for certain, that code needs to be in a function. Period. Sounds like your book just left out pieces of the code, and assumed that you''d fill them in.

Trust me on this. All executed statements must be present in a function. Period.
That is the code for initilializing the primary screen surface and like all C code in need to be in a function.
Hey thank for the help it works now. sorry for my mistake about memset().

This topic is closed to new replies.

Advertisement