Thread: Wierd error

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    114

    Wierd error

    Hi I added some code from an example in the sdl docs. I can't see why its a problem but I am getting this error for all 4 of the lines it runs:
    "expected `,' or `;' before '=' token"

    Anyway Here is the code

    Code:
    Uint32 rmask, gmask, bmask, amask;
    
    #if SDL_BYTEORDER == SDL_BIG_ENDIAN
        rmask = 0xff000000;
        gmask = 0x00ff0000;
        bmask = 0x0000ff00;
        amask = 0x000000ff;
    #else
        rmask = 0x000000ff;
        gmask = 0x0000ff00;
        bmask = 0x00ff0000;
        amask = 0xff000000;
    #endif
    Any ideas? Thanks

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    You can't assign values to variables outside of a function. You could, however, intialize them:
    Code:
    #if SDL_BYTEORDER == SDL_BIG_ENDIAN
      Uint32 rmask = 0xff000000;
      Uint32 gmask = 0x00ff0000;
      Uint32 bmask = 0x0000ff00;
      Uint32 amask = 0x000000ff;
    #else
      Uint32 rmask = 0x000000ff;
      Uint32 gmask = 0x0000ff00;
      Uint32 bmask = 0x00ff0000;
      Uint32 amask = 0xff000000;
    #endif
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    114
    woops, should have spotted that. Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  4. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  5. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM