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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:02:41+00:00 2026-06-12T11:02:41+00:00

I have a loop like below, I think the problem is with the inner

  • 0

I have a loop like below, I think the problem is with the inner for loops marked “See here”. Whats the problem with that?

// measure time to write different sizes of data
for (int i = 0; i < sizeof(sizes)/sizeof(int); i++) {
    lengthMod = sizes[i]/sizeof(int) - 1;

    start = wall_clock_time();

    for (unsigned int j = 0; j < 10; j++) // << See here!!!
        tmp = 1;

    // force any write back cache to flush. read from other data source
    for (unsigned int j = 0; j < REPS; j++) // << Or here!!!
        tmp = j;

    end = wall_clock_time();
    timeTaken = ((float)(end - start))/1000000000;
    fprintf(stderr, "%d, %1.2f \n", sizes[i]/1024, ((float)(end - start))/1000000000);
}

You can see the full source on GitHub ~line 32


g++ -O3 cache-write.cpp -o cache-write -lrt
cache-write.cpp: In function ‘int main()’:
cache-write.cpp:36:27: error: expected primary-expression before ‘;’ token
cache-write.cpp:36:27: error: expected ‘)’ before ‘;’ token
cache-write.cpp:36:29: error: name lookup of ‘j’ changed for ISO ‘for’ scoping [-fpermissive]
cache-write.cpp:36:29: note: (if you use ‘-fpermissive’ G++ will accept your code)
cache-write.cpp:36:32: error: expected ‘;’ before ‘)’ token
cache-write.cpp:44:11: error: ‘data1’ was not declared in this scope
make: *** [cache-write] Error 1
  • 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-12T11:02:42+00:00Added an answer on June 12, 2026 at 11:02 am

    Instead of using #define where you declare REPS, use

    const unsigned int REPS = whatever;
    

    Generally in C++ avoid using #define because it can easily cause the kind of problem you’re having.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a foreach loop (see below) that encodes the values to htmlentities() and
Scenerio: I have some divs populated through foreach loop like below <div id=div1><input type=hidden
I have a loop that can look like this: For Each article In artAll
I have a loop that runs through a variety of websites and I'd like
I have a while loop like below. I want to sum all of the
I have a loop like this: for i=1:no %some calculations fid = fopen('c:\\out.txt','wt'); %write
Does clojure have a powerful 'loop' like common lisp. for example: get two elements
I have a for each loop like this $sn_count = 1; $prodfilter = ;
I have loop and each iteration of Hash looks like this: [1, {:clid=>1, :nvz=>4,
I have two nested loop in XSL like this, at this moment I use

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.