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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:29:48+00:00 2026-05-27T10:29:48+00:00

I am developing a C program and have been stumped by this warning. I

  • 0

I am developing a C program and have been stumped by this warning. I want to retrieve arguments from the list using va_arg.

args[i] = (int) va_arg(argptr, int); 

or

args[i] = (char) va_arg(argptr, char);

the problem that am getting this warning:

... void *' differs in levels of indirection from 'int'...

the same also for char case.
Any explanation for that?

code:

void test_function(va_list argptr, int (*callback)(),
                   int ret_typel)
{
  int i ;
  int arg_typel;
  int no_moreb = TRUE;
  void *args[MAX_FUNCTION_ARGS];
  for (i=0; no_moreb; i++) {
    arg_typel = (int)va_arg(argptr, int);
    switch(arg_typel) {
    case F_INT:
      args[i] = (int) va_arg(argptr, int);
      break;
    case F_CHAR:
      args[i] = (char) va_arg(argptr, char);
      break;
    default:
      no_moreb = FALSE;
      i--;
      break;
    }
  }
}
  • 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-27T10:29:48+00:00Added an answer on May 27, 2026 at 10:29 am

    The problem is that args[] is an array of void *. You cannot assign an int or float to a void * (it doesn’t make any sense). You could get round this by casting, but it’s not a good idea.

    If you want to store different types in the same variable, consider a union:

    typedef union
    {
        char  c;
        int   i;
        float f;
    } MyUnion;
    
    MyUnion args[MAX_FUNCTION_ARGS];
    
    args[i].c = va_arg(argptr, char);
    args[i].i = va_arg(argptr, int);
    args[i].f = va_arg(argptr, float);
    

    UPDATE
    As Jonathan Leffler correctly points out in his answer, va_arg(argptr, char) and va_arg(argptr, float) should not be used, due to default promotions for variadic functions.

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

Sidebar

Related Questions

I have been developing my program on my desktop, and now want to continue
A sselenium program I have been developing for a while now comes up with
I have been developing a Java application using J2EE and a Derby database. My
I have been developing a program lately that compiles and runs a C++ Program
I have been developing a parental control software program for my company, but have
I have a WPF program that I'm developing in which I want to catch
I am developing a C# program, and i have one function that consumes too
I have a C# game program that i'm developing. it uses sound samples and
I am currently developing a program that uses C#'s Dictionary container (specifically, SortedDictionary). This
I am developing a program where I find myself doing this like this a

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.