Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral


  • Rank

    [SDL] 'operator ' is ambiguous

    Quote:Original post by artm your code compiles clean with gcc. I am using VC6.0, SP5 Quote:Original post by artmthe first thing i'd try in your case would be putting SDL_GetTicks()-start in parentheses. I did tried that but still the same error.

    [SDL] 'operator ' is ambiguous

    Quote:Original post by Fruny Didn't the compiler tell you what were the different possibilities? This is the complete source //The headers #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include "SDL/SDL_ttf.h" #include <string> #include <sstream> //Screen attributes const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; const int SCREEN_BPP = 32; //The surfaces SDL_Surface *background = NULL; SDL_Surface *startStop = NULL; SDL_Surface *seconds = NULL; SDL_Surface *screen = NULL; //The event structure SDL_Event event; //The font TTF_Font *font = NULL; //The color of the font SDL_Color textColor = { 0xF0, 0xFF, 0xF0 }; SDL_Surface *load_image( std::string filename ) { //The image that's loaded SDL_Surface* loadedImage = NULL; //The optimized surface that will be used SDL_Surface* optimizedImage = NULL; //Load the image loadedImage = IMG_Load( filename.c_str() ); //If the image loaded if( loadedImage != NULL ) { //Create an optimized surface optimizedImage = SDL_DisplayFormat( loadedImage ); //Free the old surface SDL_FreeSurface( loadedImage ); //If the surface was optimized if( optimizedImage != NULL ) { //Color key surface SDL_SetColorKey( optimizedImage, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB( optimizedImage->format, 0, 0xFF, 0xFF ) ); } } //Return the optimized surface return optimizedImage; } void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL ) { //Holds offsets SDL_Rect offset; //Get offsets offset.x = x; offset.y = y; //Blit SDL_BlitSurface( source, clip, destination, &offset ); } bool init() { //Initialize all SDL subsystems if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) { return false; } //Set up the screen screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE ); //If there was in error in setting up the screen if( screen == NULL ) { return false; } //Initialize SDL_ttf if( TTF_Init() == -1 ) { return false; } //Set the window caption SDL_WM_SetCaption( "Timer Test", NULL ); //If everything initialized fine return true; } bool load_files() { //Load the background image background = load_image( "background3.png" ); //Open the font font = TTF_OpenFont( "lazy.ttf", 36 ); //If there was a problem in loading the background if( background == NULL ) { return false; } //If there was an error in loading the font if( font == NULL ) { return false; } //If everything loaded fine return true; } void clean_up() { //Free the surfaces SDL_FreeSurface( background ); SDL_FreeSurface( startStop ); //Close the font TTF_CloseFont( font ); //Quit SDL_ttf TTF_Quit(); //Quit SDL SDL_Quit(); } int main( int argc, char* args[] ) { //Quit flag bool quit = false; //The timer starting time Uint32 start = 0; //The timer start/stop flag bool running = true; //Initialize if( init() == false ) { return 1; } //Load the files if( load_files() == false ) { return 1; } //Generate the message surface startStop = TTF_RenderText_Solid( font, "Press S to start or stop the timer", textColor ); //Start the timer start = SDL_GetTicks(); //While the user hasn't quit while( quit == false ) { //While there's an event to handle while( SDL_PollEvent( &event ) ) { //If a key was pressed if( event.type == SDL_KEYDOWN ) { //If s was pressed if( event.key.keysym.sym == SDLK_s ) { //If the timer is running if( running == true ) { //Stop the timer running = false; start = 0; } else { //Start the timer running = true; start = SDL_GetTicks(); } } } //If the user has Xed out the window else if( event.type == SDL_QUIT ) { //Quit the program quit = true; } } //Apply the background apply_surface( 0, 0, background, screen ); //Apply the message apply_surface( ( SCREEN_WIDTH - startStop->w ) / 2, 200, startStop, screen ); //If the timer is running if( running == true ) { //The timer's time as a string std::stringstream time; //Convert the timer's time to a string time << "Timer: " << SDL_GetTicks() - start; //Render the time surface seconds = TTF_RenderText_Solid( font, time.str().c_str(), textColor ); //Apply the time surface apply_surface( ( SCREEN_WIDTH - seconds->w ) / 2, 50, seconds, screen ); //Free the time surface SDL_FreeSurface( seconds ); } //Update the screen if( SDL_Flip( screen ) == -1 ) { return 1; } } //Clean up clean_up(); return 0; } There's only 1 error error C2593: 'operator <<' is ambiguous
  3. This is the code in which I am having errors //If the timer is running if( running == true ) { //The timer's time as a string std::stringstream time; //Convert the timer's time to a string time << "Timer: " << SDL_GetTicks() - start; //Render the time surface seconds = TTF_RenderText_Solid( font, time.str().c_str(), textColor ); //rest of the code I am getting error as error C2593: 'operator <<' is ambiguous for this line time << "Timer: " << SDL_GetTicks() - start;
  4. These are few questions in which I am facing problem Ques 1 Which of the following would make a good subnet mask for the address a) b) c) d) Answer is (c) but I don't understand how? Is there any criteria for good subnet and bad subnet? Ques 2: What class of IP address does the subnet mask operate on? a)A b)B c)C d)A,B or C My answer (a), books answer also (a). Ques 3: What class of IP address does the subnet mask operate on? a)A b)B c)C d)A,B or C My answer (b), books answer also (d)? Ques 4: What class of IP address does the subnet mask operate on? a)A b)B c)C d)A,B or C My answer (c), books answer also (d)?
  5. In Effective C++, 2nd Edition Scott Meyer tells two ways( i.e Handle Class and Prototcol Class) to minimise compilation dependencies between files(Item34). But I wanted to know when should I prefer one over other to reduce compilation dependencies? Should I always stick with Handle Class or should always stick with Protocol class? Are there any guidelines? [Edited by - TEUTON on September 11, 2006 9:41:49 PM]
  6. Why do always non-static const and non-static reference data members need to be initialised in initilisation lists?
  7. I got it. Thank You.
  8. I recently came to know that endl(cout); and cout<<endl; result in the same thing. But, are they internally the same thing? What I mean is: In cout<<endl; it is a call to operator<< and in case of endl(cout), it appears like a function call. Can someone elaborate on this?
  9. I just started reading C++ Templates: The Complete Guide By David Vandevoorde, Nicolai M. Josuttis In the beginning chapter author says Quote:This is not a book about the C++ standard library, but we do make use of that library in some of our examples. In general, we use the C++-specific headers (for example, <iostream> rather than <stdio.h>). The exception is <stddef.h>. We use it instead of <cstddef> and therefore do not qualify size_t and ptrdiff_t with the std:: prefix because this is still more portable and there is no advantage in using std::size_t instead of size_t. I can't understand why author say that size_t is more portable than std::size_t and why std::size_t is not having any advantage over size_t.
  10. This is what I think First Standard of C++ - ISO/IEC 14882:1998 Second Standard of C++ - ISO/IEC 14882:2003 Ques-1 Does second standard(ISO/IEC 14882:2003) also called TR1 or TR1 is something else. Ques-2 Can we now safely say that C++ 98 is obsolete?
  11. TEUTON

    From a Software User's Perspective

    Mention Not :)
  12. Why is it that Microsoft's products keep mushrooming in size with each new release always requiring significantly more disk space and more processing power than the last time? They might claim it's because of all the new features they add each time, but that's only half the story. The new features and the increased processing requirements are designed to fuel the process of perpetual upgrades. This is Microsoft's way of rubbing Intel's back so that Intel will give Microsoft preferential treatment when it comes out with new chip specs. It's also Microsoft's way of convincing consumers that their newer product versions are better because they are so much bigger. Their new features are often superfluous but users must still deal with the overhead required by the features even though most will never use the features.
  13. Wanted to know whether stack unwinding is impementation dependent or it should always occur when a suitable handler is not found.
  14. So, basically we need to be const correct.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!