Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
can't compile c++ code

 
Post new topic   Reply to topic Printable version
 View previous topic  dev c++ open gl problem Post :: Post c# - saving images to file  View next topic  
Author Message
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Fri May 09, 2008 7:41 pm    Post subject: can't compile c++ code Reply to topic Reply with quote

I was learning SDL tutorial but it did not compile my code neither on DEVC++ or VC++

here is code

Code: Show/Hide
#include <sdl.h>
#include <string.h>

const int screen_w = 500;
const int screen_h = 500;
const int screen_bpp = 32;

SDL_Surface *message = NULL;
SDL_Surface *background = NULL;
SDL_Surface *screen = NULL;

SDL_Surface *load_image(std::string fileName)
{
   SDL_Surface* loadedImage = NULL;
   SDL_Surface* optimizedImage = NULL;

   loadedImage = SDL_LoadBMP(fileName.c_str());

   if (loadedImage!=NULL)
   {
      optimizedImage = SDL_DisplayFormat(loadedImage);

      SDL_FreeSurface(loadedImage);
   }

   return optimizedImage;
}

void apply_surface(int x,int y, SDL_Surface* source, SDL_Surface destination)
{
   SDL_Rect offset;

   offset.x = x;
   offset.y = y;

   SDL_BlitSurface(source,NULL,destination,&offset);
}

int main(int argc, char* args[])
{

   if (SDL_Init(SDL_INIT_EVERYTHING)== -1))
   {
      return 1;
   }

   screen = SDL_SetVideoMode(screen_w,screen_h,screen_bpp,SDL_SWSURFACE);

   if (screen == NULL)
   {
      return 1;
   }

   SDL_WM_SetCaption("A3 Pokemon 2",NULL);

   message = load_image("logo.bmp");
   background = load_image("bg.bmp");

   apply_surface(0,0,background,screen);
   apply_surface(102,175,message,screen);

   if (SDL_Flip == -1)
   {
      return 1;
   }

   SDL_Delay(3000);

   SDL_FreeSurface(backround);
   SDL_FreeSurface(message);


   SDL_Quit();

   return 0;
}



here are the errors

Code: Show/Hide
1>------ Build started: Project: A3 Pokemon 2, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(12) : error C2653: 'std' : is not a class or namespace name
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(12) : error C2065: 'string' : undeclared identifier
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(12) : error C2146: syntax error : missing ')' before identifier 'fileName'
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(12) : error C2059: syntax error : ')'
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(13) : error C2143: syntax error : missing ';' before '{'
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(13) : error C2447: '{' : missing function header (old-style formal list?)
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(36) : error C2664: 'SDL_UpperBlit' : cannot convert parameter 3 from 'SDL_Surface' to 'SDL_Surface *'
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(42) : error C2059: syntax error : ')'
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(56) : error C2064: term does not evaluate to a function taking 1 arguments
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(57) : error C2064: term does not evaluate to a function taking 1 arguments
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(59) : error C2664: 'apply_surface' : cannot convert parameter 4 from 'SDL_Surface *' to 'SDL_Surface'
1>        No constructor could take the source type, or constructor overload resolution was ambiguous
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(60) : error C2664: 'apply_surface' : cannot convert parameter 4 from 'SDL_Surface *' to 'SDL_Surface'
1>        No constructor could take the source type, or constructor overload resolution was ambiguous
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(62) : error C2446: '==' : no conversion from 'int' to 'int (__cdecl *)(SDL_Surface *)'
1>        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(62) : error C2040: '==' : 'int (__cdecl *)(SDL_Surface *)' differs in levels of indirection from 'int'
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(69) : error C2065: 'backround' : undeclared identifier
1>Build log was saved at "file://c:\Documents and Settings\Owner\Desktop\Programing\c++\A3 Pokemon 2 VC version\A3 Pokemon 2\A3 Pokemon 2\Debug\BuildLog.htm"
1>A3 Pokemon 2 - 15 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Fri May 09, 2008 8:23 pm    Post subject: Reply to topic Reply with quote

Just check the damn errors... the first one:

std is not a class or namespace... once you get that everything fucks up. I have no idea why there is 'std::string' in there, especially since <string.h> is included, just use 'string'

(old-style formal list?) might refer to the use of std::... dunno.

and... backround instead of background...
(69) : error C2065: 'backround' : undeclared identifier

how is that not obvious?

Read the errors sloooooowly next time... They are there for a reason. Even if you don't understand anything (which often happens), you get the line number. Go see that line, and check what is wrong.
_________________
(Insert a bunch of dead links here)
Back to top
View users profile Send private message Add User to Ignore List
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Fri May 09, 2008 8:57 pm    Post subject: Reply to topic Reply with quote

EDIT i got it to 1 error but i have no idea how to fix it
Code: Show/Hide
1>------ Build started: Project: A3 Pokemon 2, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(62) : error C2446: '==' : no conversion from 'int' to 'int (__cdecl *)(SDL_Surface *)'
1>        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\owner\desktop\programing\c++\a3 pokemon 2 vc version\a3 pokemon 2\a3 pokemon 2\main.cpp(62) : error C2040: '==' : 'int (__cdecl *)(SDL_Surface *)' differs in levels of indirection from 'int'
1>Build log was saved at "file://c:\Documents and Settings\Owner\Desktop\Programing\c++\A3 Pokemon 2 VC version\A3 Pokemon 2\A3 Pokemon 2\Debug\BuildLog.htm"
1>A3 Pokemon 2 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sat May 10, 2008 12:19 am    Post subject: Reply to topic Reply with quote

future reminder: you should tell us which line is line 62... cause we have to copy-paste it in notepad, and then scroll to find the line... while you could save us that time since you have the line numbers written in the IDE.


From what I understand, SDL_Flip is some kind of pointer (could you get the declaration of SDL_Flip?; go in the sdl.h file you should find it)
So it tries to compare that thing, with -1. To do that, it must convert SDL_Flip to the same type as -1, which is an int. And apparently, it cannot.
So... since I have no idea what SDL_Flip is, I can't help you more :/
Back to top
View users profile Send private message Add User to Ignore List
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Sat May 10, 2008 12:35 pm    Post subject: Reply to topic Reply with quote

This is what i found when i searched for delcaration and definition,
Code: Show/Hide
extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen);


and its declared as an int :\


EDIT: the guy that made that tutorial made over 20 errors, i got it all fixed up turns out flip was a function..
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sat May 10, 2008 1:49 pm    Post subject: Reply to topic Reply with quote

SDL_Flip is a function and not an integer.
_________________
It's a shark! Oh my god! Unbelievable!
Back to top
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sat May 10, 2008 3:58 pm    Post subject: Reply to topic Reply with quote

What kind of function? Does it return an int?
Then it should be
if (SDL_Flip() == -1)
Back to top
View users profile Send private message Add User to Ignore List
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Sat May 10, 2008 4:31 pm    Post subject: Reply to topic Reply with quote

yes it does but it reqiures 1 parameter i fixed it up, SDL_Flip(screen)==-1
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 689 page(s) served in previous 5 minutes.

phpBB Created this page in 0.436669 seconds : 33 queries executed (92.8%): GZIP compression disabled