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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:29:49+00:00 2026-05-26T00:29:49+00:00

I am in need of mixing C code with C++ code in a computer

  • 0

I am in need of mixing C code with C++ code in a computer simulation.

A C library has functions which take references to a regular array of doubles:

void position(double[3])

Another C library defines its own vector type:

void do_something(*custom_vector)

And my front-end (in C++) uses boost::numeric::ublas::vector.

In the first case, I have a lot of places with this kind of code:

double tmp[3];
position(tmp)
boostvec r(3);
r(0) = tmp[0]; r(1) = tmp[1]; r(2) = tmp[2];
// continue working with r

also

custom_vector *v;
do_something(v);
boostvec r(3);
r(0) = v[0]; r(1) = v[1]; r(2) = v[2];

Internally, all the types are ultimately vector containers, but their slight implementation differences are causing a lot of boilerplate explosion. I am also dealing with a lot different versions of double (some define realtype (which is a double), others define number (which is a double), etc).

How do you deal with this situation?

Thank you.

  • 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-26T00:29:49+00:00Added an answer on May 26, 2026 at 12:29 am

    As long as both source and destination types support the standard iterator interface (which is true for std::vector, arrays, and every Boost sequence type I can think of; so you just need to fix your custom_vector), and as long as there are implicit conversions possible between the numeric types, you should be able to just use std::copy.

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

Sidebar

Related Questions

I'm working off of some of Apple's sample code for mixing audio ( http://developer.apple.com/library/ios/#samplecode/MixerHost/Introduction/Intro.html
We are creating a javascript library from scratch and we need some utilities functions,
I need to copy hundreds of gigs of random files around on my computer
I need to solve the following question which i can't get to work by
i have a input tag which is non editable, but some times i need
I have some code which must be thread safe whose behavior resembles this: protected
I need to get userPrincipal inside a piece of Javascript code. My app currently
In order to improve type safety in some C library code, I got the
So I'm writing some code and have recently come across the need to implement
Is there a way to emulate mixins or traits in java? basically, I need

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.