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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:19:23+00:00 2026-05-10T17:19:23+00:00

I have got a C function in a static library, let’s call it A,

  • 0

I have got a C function in a static library, let’s call it A, with the following interface :

int A(unsigned int a, unsigned long long b, unsigned int *y, unsigned char *z); 

This function will change the value of y an z (this is for sure). I use it from within a dynamic C++ library, using extern ‘C’.

Now, here is what stune me :

  • y is properly set, z is not changed. What I exactly mean is that if both are initialized with a (pointed) value of 666, the value pointed by y will have changed after the call but not the value pointed by z (still 666).
  • when called from a C binary, this function works seamlessly (value pointed by z is modified).
  • if I create a dummy C library with a function having the same prototype, and I use it from within my dynamic C++ library, it works very well. If I re-use the same variables to call A(..), I get the same result as before, z is not changed.

I think that the above points show that it is not a stupid mistake with the declaration of my variables.

I am clearly stuck, and I can’t change the C library. Do you have any clue on what can be the problem ? I was thinking about a problem on the C/C++ interface, per instance the way a char* is interpreted.

Edit : I finally found out what was the problem. See below my answer.

  • 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. 2026-05-10T17:19:23+00:00Added an answer on May 10, 2026 at 5:19 pm

    First of all, I am very grateful to everyone for your help. Thanks to the numerous ideas and clues you gave me, I have been able to finally sort out this problem. Your advices helped me to question what I took for granted.

    Short answer to my problem : The problem was that my C++ library used an old version of the C library. This old version missed the 4th argument. As a consequence, the 4th argument was obviously never changed.

    I am a bit ashamed now that I realised this was the problem. However, I was misslead by the fact that my code was compiling fine. This was due to the fact that the C++ library compiled against the correct version of the C lib, but at runtime it used the old version statically linked with another library that I was using.

    C++ Lib (M) ---> dyn C++ lib (N) ---> C lib (P) v.1.0      |      ------> C lib (P) v.1.1 

    (N) is a dynamic library which is statically linked with (P) version 1.0. The compiler accepted the call from (M) to the function with 4 arguments because I linked against (P) version 1.1, but at runtime it used the old version of (P).

    Feel free to edit this answer or the question or to ask me to do so.

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

Sidebar

Ask A Question

Stats

  • Questions 217k
  • Answers 217k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This seems to describe a B+ tree perfectly: http://en.wikipedia.org/wiki/B%2B_tree :… May 12, 2026 at 11:26 pm
  • Editorial Team
    Editorial Team added an answer You just use the INSERTED clause again, such as in… May 12, 2026 at 11:26 pm
  • Editorial Team
    Editorial Team added an answer That's not how manipulators work - it's all about types.… May 12, 2026 at 11:26 pm

Related Questions

I have got a C function in a static library, let's call it A,
I have yet to find a good reference on this topic. For this example
I need to manipulate data in fixed array involving mid insertion. Rather than using
I've been working non-stop for the last three days on a completely managed interface
I've got a function in C#, and I'd like to port it (among some

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.