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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:30:23+00:00 2026-06-04T11:30:23+00:00

I have a small problem with a code written below. VS 2010 compiles it,

  • 0

I have a small problem with a code written below. VS 2010 compiles it, runs and I get the predicted result. But when I tried to compile this code with Qt Creator I get this warning every time: “Expected token ‘)’ got int”. Yes, program will be run by Qt Creator, but the program will blow up. What’s wrong with this code:

#include <stdio.h>
#include <stdarg.h>
#define ARR_SIZE 2

int **getAddresses(int amount, ...)
{
    static int *arr[ARR_SIZE] = {};
    va_list vl;

    if(amount > 0)
    {
        va_start(vl, amount);
        int i;
        for(i = 0; i < amount; i++)
        {
            *(arr + sizeof(int) * i) = va_arg(vl, int*);  //This one is highlighted by the Qt Creator.
        }
        va_end(vl);
        return 0;
    }
    else
    {
        return arr;
    }
}

int main(void)
{
    int a = 3, b = 5;

    getAddresses(ARR_SIZE, &a, &b);
    printf("BEFORE: %d, %d\n", a, b);

    int **res = getAddresses(0), i;
    for(i = 0; i < ARR_SIZE; i++)
    {
        *(*(res + sizeof(int) * i)) += 5;
    }

    printf("AFTER: %d, %d\n", a, b);

    return 0;
}

Thank you for your answers beforehand.

ADDED: Qt Creator highlights this line of code *(arr + sizeof(int) * i) = va_arg(vl, int*);

Furthermore Dev++ is able to run this code without any warning and errors or crushing.

GCC is able to compile it under Fedora linux 14:

[Admin@localhost testerprog]$ gcc tester.c -o tester
[Admin@localhost testerprog]$ ls
tester  tester.c
[Admin@localhost testerprog]$ ./tester
BEFORE: 3, 5
AFTER: 8, 10
[Admin@localhost testerprog]$ 

GCC version is 4.5.1 20100924 (Red Hat 4.5.1-4)

  • 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-04T11:30:24+00:00Added an answer on June 4, 2026 at 11:30 am

    — Edited, as the original post is a bit wrong, but the same line is likely the cause —

    Since the error specifically mentioned finding an int instead of a closing parenthesis, I would suspect the offending line is

            *(arr + sizeof(int) * i) = va_arg(vl, int*);
    

    And while your code is valid C / C++, I would reverse my suspicion that the VS compiler made a mistake, but offer a similar suspicion that the Qt compiler either

    1. Has a bug in it and is expecting a R value, not a type.
    2. Has wrapped va_arg references in some other qt_xxx style wrapper to allow proper compiling in the QT framework.

    — Original post follows —

    int is a keyword in C / C++ so you cannot use it as a variable safely. It seems that the line

            *(arr + sizeof(int) * i) = va_arg(vl, int*);
    

    asks for the value of the address held by a variable, int, not the value referenced by an int pointer. Odds are that the VS compiler’s error checking isn’t as robust, leading to silent acceptance of the error.

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

Sidebar

Related Questions

I have a small problem with interfaces. Here it is in Pseudo code :
Im having a small problem with my code. I have been trying to read
I have a small problem during debugging my App in VS 2010 RC when
I have written a small piece of code which handles the input of a
I have written some code in which a small part of the code takes
I have a small bit of code that runs in an applet that contains
I am having some strange problem. I have written a small module in VC++
have small problem, and would very much appreciate help :) I should convert byte
I have a small problem with Smarty... I have two different template files in
I have a small problem where I want to find the next active item

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.