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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:25:56+00:00 2026-05-16T16:25:56+00:00

This situation can only occur without name mangling (I believe), so the below code

  • 0

This situation can only occur without name mangling (I believe), so the below code is C.
Say there is a function A defined in A.c as

void A(int x, int y){
    //Do stuff
}

Now there is also a separate file B.c:

extern "C"{
    void A(int x, int y, int z);
}

void B(){
    A(1, 2, 3);
}

A is initially declared to have only 2 arguments yet when declared in B.c it has an extra one, and it is called with that third in B().
I know it is possible to make this situation occur, for example when linking with fortran subroutines, OR when dynamically linking.

I imagine it is unsafe to pass an extra argument to a function, can anyone explain what is happening in memory when a function is called and arguments are passed to it? And, therefore, how safe it is to pass this “extra” argument that is neither used nor wanted.

Is it possible that the extra argument overwrites a space in memory that is used within the function? Or does the function call to A allocate space in memory for the arguments then tell A where the beginning of the argument memory block is, A reads out the first two arguments and ignores the last, making it completely safe?

Any information on the function would be greatly enlightening, thanks.

  • 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-16T16:25:57+00:00Added an answer on May 16, 2026 at 4:25 pm

    Linkage is implementation-defined, so there is no way to say definitely.

    That said, other features of C (notably vardic parameters) force an implementation that would usually allow it.

    For example, I don’t know of any implementation that would fail if you wrote:

     printf("%d", 1, 2);
    

    It would, however, merely print “1”.

    Many people here are bringing up cdecl, pascal and __stdcall calling conventions. However, none of those are part of the Standard and are all features of certain implementions,. which bring us back to my first sentence.

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

Sidebar

Related Questions

Can someone explain why, in this situation, scandir is getting my directory, but the
How can I get java classes from an xml file? In this situation, I
G'day, Edit: While this question covers a situation that can arise in programming a
Hoping that someone can help clear up this very annoying situation I find myself
This is a complicated situation (for me) that I'm hopeful someone on here can
In this situation I have two models, Comment and Score. The relationship is defined
I have this situation: $(#button).toggle(function(){ $(#window).animate({top:'0%'},1000); },function(){ $(#window).animate({top:'-100%'},1000); }); but I need change it
I came across this situation while migrating our DB from Foxpro to SQL. Below
Maybe there's someone out in the ether that can help me with this one.
How can i get the DOM element which fired onclick, in this situation :

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.