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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:13:29+00:00 2026-06-13T10:13:29+00:00

So I’ve been making a custom parser for a scripting language, and I wanted

  • 0

So I’ve been making a custom parser for a scripting language, and I wanted to be able to pass only ellipses arguments. I don’t need or want an initial variable, however Microsoft and C seem to want something else. FYI, see bottom for info.

I’ve looked at the va_* definitions

#define _crt_va_start(ap,v)  ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) )
#define _crt_va_arg(ap,t)    ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
#define _crt_va_end(ap)      ( ap = (va_list)0 )

and the part I don’t want is the v in va_start. As a little background I’m competent in goasm and I know how the stack works so I know what’s happening here. I was wondering if there is a way to get the function stack base without having to use inline assembly.

Ideas I’ve had:

#define im_va_start(ap) (__asm { mov [ap], ebp })

and etc… but really I feel like that’s messy and I’m doing it wrong.

struct function_table {
    const char* fname;
    (void)(*fptr)(...);
    unsigned char maxArgs;
};
function_table mytable[] = {
{ "MessageBox", &tMessageBoxA, 4 } };

… some function that sorts through a const char* passed to it to find the matching function in mytable and calls tMessageBoxA with the params. Also, the maxArgs argument is just so I can check that a valid number of parameters is being sent. I have personal reasons for not wanting to send it in the function, but in the meantime we can just say it’s because I’m curious.

This is just an example; custom libraries are what I would be implementing so it wouldn’t just be calling WinAPI stuff.

void tMessageBoxA(...) {
// stuff to load args passed
MessageBoxA(arg1, arg2, arg3, arg4);
}

I’m using the __cdecl calling convention and I’ve looked up ways to reliably get a pointer to the base of the stack (not the top) but I can’t seem to find any. Also, I’m not worried about function security or typechecking.


edit: Thanks for input, it appears it wasn’t possible.

My fix has ended up being

    #define im_va_start(ap) {\
        __asm push eax\
        __asm mov eax, ebp\
        __asm add eax, 8h\
        __asm mov ap, eax\
        __asm pop eax\
    }

And then I can continue as normal.

As for why I require it, I’m doing some (unique) read: unsafe tricks and using a struct array with a pointer to the function as defined above. Since each function is unique, and most are from my custom library, they have… different behaviors. I don’t really know how to explain it, but I’ll release the source when I finish the POC.

I’m not really worried about portability so that’ll have to work. Also, for counting the args I did:

#define im_va_count(ap, num, t) {\
for(num = 0; *(t*)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) > 0; ++num){ }\
--num;\
im_va_start(argptr);\
}

which works for me. If anyone’s interested…

  • 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-13T10:13:30+00:00Added an answer on June 13, 2026 at 10:13 am

    Unfortunately this is not possible, the C standard says:

    A function may be called with a variable number of arguments of varying types. As
    described in 6.9.1, its parameter list contains one or more parameters.

    And the ... doesn’t count as the “one or more parameters”. Further,

    The va_start macro shall be invoked before any access to the unnamed arguments.

    That it should be called like

    va_start(va_list, parmN)
    

    And that

    The parameter parmN is the identifier of the rightmost parameter in the variable
    parameter list in the function definition (the one just before the , ...).

    So as you can see, you cannot have a variadic function without at least one parameter before the ellipsis in standard C++. The non-portable assembly trick is the closest you can come.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to

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.