Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7631129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:16:28+00:00 2026-05-31T06:16:28+00:00

Here is the piece of code that I am getting error, SDL_Rect’s definition is

  • 0

Here is the piece of code that I am getting error, SDL_Rect’s definition is copied over from documentation:

typedef struct{
  Sint16 x, y;
  Uint16 w, h;
} SDL_Rect;


SDL_Rect clips[4];

clips[0].x = 0;
clips[0].y = 0;
clips[0].w = 100;
clips[0].h = 100;

Here is how I am compiling it:

gcc -march=native -static-libgcc -o sprite sprite.c functions.o -L/usr/lib -lSDL -lpthread -lm -ldl -lpthread -lSDL_image

Here is the error that I am getting: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token for each line of clips[..] . I have tried putting paranthesis around clips[..] but It didn’t work either. This is plain “C” by the way. Not C++.

Edit

I have copied over SDL_Rect here from SDL’s documentation in order to show what it was. It is not actually in the source file I am using. Therefore, missing of the semicolon cannot be the issue. And this code is in the global scope.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:16:29+00:00Added an answer on May 31, 2026 at 6:16 am

    This (-initialisation-) assignment is at global scope which is not possible.

    It is possible to initialise the array:

    SDL_Rect clips[4] = {
                            { 0, 0, 100, 100 }, /* Element 0 initial values */
                            { 1, 1, 200, 200 }  /* Element 1 initial values */
                                                /* Element 2 and 3 unspecified so
                                                   zero initialised. */
                        };
    

    If C99 compliant compiler you can explicitly state the variables being initialised:

    SDL_Rect clips[4] = {
                            { .x = 0, .y = 0, .w = 100, .h = 100 }
                        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the piece of code that I have used for Java 5.0 TreeSet<Integer>
Here's a piece of code that takes most time in my program, according to
Here is an interesting piece of code that my fellow team members were just
I have a piece of code here that i really could use some help
I have a piece of code here that does not work despite me using
Basically my problem is that i've adapted a piece of code found here http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/62e70670-f306-4bb7-8684-549979af91c1
Here's a piece of code from the xss_clean method of the Input_Core class of
Why am I getting an error for this piece of code?: function catchevent() {
I have a piece of code that I have been getting help on and
I'm think something like Facebook apps here. User generated pieces of code that people

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.