473,327 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Combining C and C++ codes

Hi all,

I have an Opencv face detection code that is written in C. I am currently doing a face detection project that makes use of Euresys frame grabbers. The problem is the image acquisition codes for Euresys are all written in C++, and i have to pass the frames captured to the face detection program for real time face tracking.

Will it be feasible to combine C and C++ codes?
Sep 24 '06 #1
1 7370
Banfa
9,065 Expert Mod 8TB
Yes it is possible, but you will have a few problems to overcome.

1. C can not use classes (seems obvious but I thought I'd mention it).

2. C and C++ use different function calling conventions. C++ can be told use the C calling convention but C can not use the C++ calling convention.

You will often see code like this in a header file

Expand|Select|Wrap|Line Numbers
  1. #ifdef  __cplusplus
  2. extern "C" {
  3. #endif
  4.  
  5. // Header file definitions
  6.  
  7. #ifdef __cplusplus
  8. }
  9. #endif
  10.  
This is used in a header file that contains the definitions for a C source file. All C++ compilers define __cplusplus when compiling C++ source files so basically what these directives do is tell the C++ compiler to use C calling convention for anything between the { and }. This allows the C++ and C csource code to call these functions.

There are many tricks to pull with this, for instance you can declare a function in a C++ file with C calling convention, then C code can call that function but because it is in a C++ file it can use C++ features, like access to classes.

I have worked on several projects that have mixed C and C++ code, it just takes a little care.
Sep 24 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: John | last post by:
I currently have a list box that contains regions in the US (Northeast, Midwest, South, etc.). I am retrieving this data from my Region table(see below). Users have the ability to select a region...
2
by: Chris Mullins | last post by:
I've spent a bit of time over the last year trying to implement RFC 3454 (Preparation of Internationalized Strings, aka 'StringPrep'). This RFC is also a dependency for RFC 3491...
3
by: alwayswinter | last post by:
I currently have a form where a user can enter results from a genetic test. I also have a pool of summaries that would correspond to different results that a user would enter into the form. I...
7
by: Barry | last post by:
Hi all, I've noticed a strange error on my website. When I print a capital letter P with a dot above, using & #7766; it appears correctly, but when I use P& #0775 it doesn't. The following...
3
by: hurry | last post by:
I have two different set of codes (say A and B workspaces) I want to call the entire B as a function inside A.I want a solution to do this. To my knowledge, one soltn. would b to add all files of...
74
by: Beany | last post by:
Hi, I have got an ADD button with the following code: Private Sub addrec_Click() On Error GoTo Err_addrec_Click DoCmd.GoToRecord , , acNewRec Exit_addrec_Click:
1
by: scolivas | last post by:
Hi, I have 2 databases - ALdata & SPdata I have 2 tables - vewDemoData (in ALData) & vewDemoDataSP in (SPData) both of these tables are identical in design, only the records are diff. I need...
5
by: Tristan Miller | last post by:
Greetings. Is it possible using HTML and CSS to represent a combining diacritical mark in a different style from the letter it modifies? For example, say I want to render Å‘ (Latin small letter...
2
by: testar | last post by:
Hi there, I am trying to do a similar thing here with access n vb but with a few additions. Please take a look. I have a table that looks like this: ID Product Total 1 aaa 10 2 ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.