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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:21:53+00:00 2026-06-05T08:21:53+00:00

I have this issue with one of my functions in this C++ program I’m

  • 0

I have this issue with one of my functions in this C++ program I’m porting over from HP-UX to LINUX. Basically, what seems to be the problem is that for the function

const char * Dictionary::lookup(const DictionaryKey &, ...)

the gcc compiler appears to be complaining that I cannot pass objects of type const Dictionary through …

The source code for the program is pretty old and looks to utilize a lot of C-style constructs. This particular function accepts a variable list of arguments as allowed through the stdarg.h header. In addition, the warning is only reported in gcc (version 2.95.2) for HP-UX and not in LINUX’s gcc (version 4.3.2).

$ gcc -lstdc++ foo1.cc foo2.cc
foo1.cc: In method `const char * Dictionary::lookup(const DictionaryKey &, ...)':
foo1.cc:178: warning: cannot pass objects of type `const DictionaryKey' through `...'

The source code for the function is available below:

const char *Dictionary::lookup (const DictionaryKey& key, ...)
{
  static char res[MAX_LINE];
  char *param[9];
  va_list ap;
  WordDictionary::iterator entry = dictionary.find (key);
  if (entry != dictionary.end())
  {
    int idx = 1;
    va_start (ap, key);
    while ((param[idx] = va_arg (ap, char *)) != NULL) idx++;
    va_end (ap);
    char *ts = (*entry).second.textdata;
    char *ts2 = res;
    while (*ts)
    {
      if (*ts == '$')
      {
        ts++;
        idx = *ts - '0';
        strcpy (ts2, param[idx]);
        ts2 += strlen(param[idx]);
        ts++;
      } else
      {
        *ts2++ = *ts++;
      }
    }  
    *ts2++ = 0;
    return res;
  }
  else
  {
    return key.keydata;     // Not found in dictionary
  }
}

I was wondering if there was a way to repair this issue. I don’t understand what is causing this warning to appear. From what I found on other websites, it appears that this warning may cause the compiled program to behave unexpectedly. Some people are saying that this should really be an error rather than a warning. I haven’t had much luck determining the cause of this problem.

  • 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-05T08:21:56+00:00Added an answer on June 5, 2026 at 8:21 am

    The warning is correct. You can only pass POD types as variable arguments — attempting to pass a non-POD type gives undefined behavior [In case anybody cares (§5.2.2/7): “If the argument has a non-POD class type (clause 9), the behavior is undefined.”]

    Since you’re treating all the other items being passed as char *, it’s probably better to pass a vector<char *> or (perhaps even better) a vector<string>. If you can update to 4.7, you can switch to the latter fairly painlessly, so something like:

    somedict.lookup(mykey, "a", "b", "c", NULL);
    

    would turn into:

    somedict.lookup(mykey, {"a", "b", "c"});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this issue with ComboBox that uses IEnumerable<Brush> as ItemsSource; the problem lies
I have seen a few posts regarding this issue but not one specific to
my issue lokks similar to this one: (link) but i have one-to-many association: <set
I'm having an issue bending my head around this one. I have a table
I have this issue, that I have to put this in every time I
I have this issue with my form that once its submitted, you will get
I have a program written in foxpro (~shudder~) that I've inherited. The issue is,
I Have a java program that does sort of this: It starts off with
Basically I have a program that has 6 sliders that send a value through
here's my issue: I have a program in the command line that has access

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.