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

  • Home
  • SEARCH
  • 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 7708743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:41:22+00:00 2026-06-01T00:41:22+00:00

I’m writing a 64bit operating system using g++, and I have a variadic function

  • 0

I’m writing a 64bit operating system using g++, and I have a variadic function like:

void DbgPrint(const char *fmt, ...);

which shall behave quite like printf.
The problem here is that g++ follows the System V ABI, and thus it passes the first arguments in RDI, RSI, RDX, RCX, R8, R9, then pushes remaining (if any) on the stack.

Using the old stdarg.h macros va_start, va_arg, etc, with cdecl, was all quite easy as va_arg just took the next element on the stack. But now those macros won’t work at all until the 7th argument.

The only possibile solutions are (IMHO):

  • Forcing g++ to create a cdecl function. This seems impossible as __attribute__((cdecl)) is deliberately and clearly highlighted as ignored.
  • Have a new set of macros that work with the new way of passing arguments.

(I’m actually working on Win, so I don’t have the glibc headers to check their implementation).

Anyone with a solution? Thanks in advance.

  • 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-01T00:41:23+00:00Added an answer on June 1, 2026 at 12:41 am

    stdarg.h is NOT part of libc, it’s part of the compiler itself. So if you’re using g++ it should have a stdarg.h that comes with it to handle this — it generally gets installed in gcc’s private include directory, which is searched automatically before the system includes.

    If you look in gcc’s stdarg.h, you see that the va_ macros are all defined to map to __builtin functions that the compiler magically knows how to deal with:

    typedef __builtin_va_list __gnuc_va_list;
    typedef __gnuc_va_list va_list;
    
    #define va_start(v,l)   __builtin_va_start(v,l)
    #define va_end(v)   __builtin_va_end(v)
    #define va_arg(v,l) __builtin_va_arg(v,l)
    

    and those builtins all understand the calling conventions that are used by the target ABI.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need to
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.