Skip to main content
GameDev.net gamedev.net
🔒 Locked

directdraw memset() problem

Started by liquid_ice_programmer May 4, 2003 at 6:34 AM 7 replies 900+ views
Original Post
liquid_ice_programmer
liquid_ice_programmer
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
don
don
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)?




liquid_ice_programmer
liquid_ice_programmer
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?
Sneftel
Sneftel
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]
liquid_ice_programmer
liquid_ice_programmer
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]
Sneftel
Sneftel
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.
Illumini
Illumini
That is the code for initilializing the primary screen surface and like all C code in need to be in a function.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.