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 7955179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:39:12+00:00 2026-06-04T03:39:12+00:00

I have the following code FRAME frameArray[5][10]; // Create the array of frames int

  • 0

I have the following code

FRAME frameArray[5][10]; // Create the array of frames
int trackBufferFull[5] = {0, 0, 0, 0, 0};// Keeps track of how full the buffer for each node is
int trackFront[5] = {0, 0, 0, 0, 0}; // Array to keep track of which is the front of the array
int trackTail[5] = {0, 0, 0, 0, 0};


// Function to add to the array (CHANGE int frame)
void addFrame (int nodeNumber, FRAME frame)
{
    //Calc tail
    int tail = trackTail[nodeNumber-1];

    // Calc frames in buffer
    int framesinBuffer = trackBufferFull[nodeNumber-1];

    if (framesinBuffer == 10)
    {
        printf("Buffer is full\n");
    }
    else
    {

        // Add frame to frameArray
        frameArray[nodeNumber-1][tail] = frame; 
        printf("\nAdded a frame in node: %i to the buffer\n", nodeNumber);

        // Increment the count
        trackBufferFull[nodeNumber-1]++;
        trackTail[nodeNumber-1] = ++trackTail[nodeNumber-1] % 10;


    }  
}

The arrays I use for frameArray is a wrap-around/cyclic array of length 10, hence why I have the code

trackTail[nodeNumber-1] = ++trackTail[nodeNumber-1] % 10;

Everything works perfectly in a standalone file, however when run inside of a larger file, I get the following compile errors:

$ cnet GARETH -m 30
compiling gareth.c
gareth.c: In function ‘addFrame’:
gareth.c:77:27: error: operation on ‘trackTail[nodeNumber + -0x00000000000000001]’ may be undefined [-Werror=sequence-point]
gareth.c: In function ‘removeFirstFrame’:
gareth.c:98:28: error: operation on ‘trackFront[nodeNumber + -0x00000000000000001]’ may be undefined [-Werror=sequence-point]
gareth.c:105:1: error: control reaches end of non-void function [-Werror=return-type]
cc1: all warnings being treated as errors

Line 77 is the line

trackTail[nodeNumber-1] = ++trackTail[nodeNumber-1] % 10;

Help.

To see the code with line numbers and the errors side by side, I’ve uploaded an image to:
https://i.stack.imgur.com/lLPnX.png

  • 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-06-04T03:39:14+00:00Added an answer on June 4, 2026 at 3:39 am

    Line 77 is the line

    trackTail[nodeNumber-1] = ++trackTail[nodeNumber-1] % 10;
    

    You are changing trackTail[nodeNumber-1] twice between sequence points: once through ++, and once through assignment.

    This is undefined behaviour.

    The remedy is to rephrase the statement, for example like so:

    trackTail[nodeNumber-1] = (trackTail[nodeNumber-1] + 1) % 10;
    

    or like so:

    trackTail[nodeNumber-1]++;
    trackTail[nodeNumber-1] %= 10;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code, z <- data.frame(a=sample.int(10),b=sample.int(10),c=sample.int(10)) letter <- c(a,c,b) # this will
I have the following code in the top frame of a two frame page:
I have the following dummy code: dt<-data.frame(country=letters[1:20],val=rnorm(20),siz=rnorm(20)) qplot(x=country,y=val,data=dt,geom=point,size=siz) Now I want to increase the
I have the following code which should make drawFrame be called every frame but
I have the following code for framset display <FRAMESET ROWS=18%,* > <FRAME SRC=./views/Title_Page.html NAME=TITLE
I have the following two frames frame 1 with name=top and frame 2 with
I have the following code: JFrame frame = new JFrame(); JScrollPane scrollPane = new
I have the following code: UIImageView *photo = [[[UIImageView alloc] initWithFrame:CGRectMake(title_bar.titleView.frame.origin.x+130, title_bar.titleView.frame.origin.y-12, 22.0, 22.0)]
In frame 1 of a very simple flash file, I have the following code:
I have the following code: UIImageView *imgView = [[UIImageView alloc]initWithFrame: description.frame]; imgView.image = [UIImage

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.