473,473 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

c calling c++ functions

hi,

i have a code written in c now merged with c++ code i mean i am
calling c functions in c++ using extern "C" but now i want to use some
objects declared and defined in c++ to be available in c code.

how can i do this?

please reply,
thanx
Dec 18 '07 #1
6 1475
teju <rao.tejasw...@gmail.comwrote:
hi,

i have a code written in c now merged with c++ code i mean
i am calling c functions in c++ using extern "C" but now i
want to use some objects declared and defined in c++ to be
available in c code.

how can i do this?
C++ grants a licence to merge C with C++. C does not. In other
words, C++ knows about C, but C does not know about C++.

You should ask your question in a C++ forum.

--
Peter
Dec 18 '07 #2
Peter Nilsson wrote:
teju <rao.tejasw...@gmail.comwrote:
>hi,

i have a code written in c now merged with c++ code i mean
i am calling c functions in c++ using extern "C" but now i
want to use some objects declared and defined in c++ to be
available in c code.

how can i do this?

C++ grants a licence to merge C with C++. C does not. In other
words, C++ knows about C, but C does not know about C++.

You should ask your question in a C++ forum.
After you check the archives of both groups, this question has been
asked more times than I care to remember.

--
Ian Collins.
Dec 18 '07 #3
On Dec 18, 12:33 pm, Peter Nilsson <ai...@acay.com.auwrote:
teju <rao.tejasw...@gmail.comwrote:
hi,
i have a code written in c now merged with c++ code i mean
i am calling c functions in c++ using extern "C" but now i
want to use some objects declared and defined in c++ to be
available in c code.
how can i do this?

C++ grants a licence to merge C with C++. C does not. In other
words, C++ knows about C, but C does not know about C++.
There is a faq on the C++ inventor's homepage talking about C and C++
call each other. Is the C mentioned on that webpage K&R C and/or ANSI
C, or is it just another kind of C in C++?

http://www.research.att.com/~bs/bs_faq2.html

How do I call a C function from C++?
How do I call a C++ function from C?
Dec 18 '07 #4
lovecreatesbea...@gmail.com wrote:
On Dec 18, 12:33 pm, Peter Nilsson <ai...@acay.com.auwrote:
>teju <rao.tejasw...@gmail.comwrote:
hi,
i have a code written in c now merged with c++ code i mean
i am calling c functions in c++ using extern "C" but now i
want to use some objects declared and defined in c++ to be
available in c code.
how can i do this?

C++ grants a licence to merge C with C++. C does not. In other
words, C++ knows about C, but C does not know about C++.

There is a faq on the C++ inventor's homepage talking about C and C++
call each other. Is the C mentioned on that webpage K&R C and/or ANSI
C, or is it just another kind of C in C++?

http://www.research.att.com/~bs/bs_faq2.html

How do I call a C function from C++?
How do I call a C++ function from C?
It is ANSI/ISO C.

Dec 18 '07 #5
Ian Collins wrote:
Peter Nilsson wrote:
teju <rao.tejasw...@gmail.comwrote:
hi,
>
i have a code written in c now merged with c++ code i mean
i am calling c functions in c++ using extern "C" but now i
want to use some objects declared and defined in c++ to be
available in c code.
>
how can i do this?
C++ grants a licence to merge C with C++. C does not. In other
words, C++ knows about C, but C does not know about C++.

You should ask your question in a C++ forum.
After you check the archives of both groups, this question has been
asked more times than I care to remember.
And the comp.lang.c++ FAQ:

<http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html>


Brian
Dec 18 '07 #6
teju <ra***********@gmail.comwrote:
i have a code written in c now merged with c++ code i mean i am
calling c functions in c++ using extern "C" but now i want to use some
objects declared and defined in c++ to be available in c code.
how can i do this?
By passing pointers and treating these pointers as opaque on the
C side. To do anything, you will have to write more extern "C"
helper functions in C++.

In general you can't manipulate C++ objects directly from C.
--
pa at panix dot com
Dec 19 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: pieter.breed | last post by:
Hi All, Is it possible to export a c# method into a dll in such a way that your "normal" C application can then call this method? To be clear: I am not asking how to use "DllImport" or...
19
by: Ross A. Finlayson | last post by:
Hi, I hope you can help me understand the varargs facility. Say I am programming in ISO C including stdarg.h and I declare a function as so: void log_printf(const char* logfilename, const...
5
by: Dave | last post by:
does calling a regular function cost any cpu time? In other words, is it faster to write the code of two functions into main(), or is it the exact same thing as calling two functions. I know its...
1
by: Mark Jerde | last post by:
Yesterday I posted the message below to microsoft.public.dotnet.languages.vb and microsoft.public.vc.language. The two replies are also posted. I need to write some ISO C++ functions, more...
1
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
1
by: H.B. | last post by:
Hi, I need to make a function that can display data on my Managed C++ app and be called by an unmanaged C++ DLL. Something like : void Form1::Form1_Load(System::Object * sender,...
2
by: Daniel Lidström | last post by:
I'm using a library called fyba. This library reads and writes files in a format called sosi. fyba uses the following code to determine if the calling process has own methods to handle errors,...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
4
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread...
10
by: sulekhasweety | last post by:
Hi, the following is the definition for calling convention ,which I have seen in a text book, can anyone give a more detailed explanation in terms of ANSI - C "the requirements that a...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.