* Query in C
2005-07-17 16:27 ` Vadiraj
@ 2005-08-01 6:10 ` avinash pawar
2005-08-01 6:44 ` Steve Graegert
0 siblings, 1 reply; 3+ messages in thread
From: avinash pawar @ 2005-08-01 6:10 UTC (permalink / raw)
To: Vadiraj; +Cc: Vikas S, Steve Graegert, Rechberger Markus, linux-c-programming
Hello Everyone ,
Can anyone of you please tell me..
what does extern "C" int func(int *,foo) accomplish ?
waiting for your reply.
regards,
Avinash
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Query in C
2005-08-01 6:10 ` Query in C avinash pawar
@ 2005-08-01 6:44 ` Steve Graegert
0 siblings, 0 replies; 3+ messages in thread
From: Steve Graegert @ 2005-08-01 6:44 UTC (permalink / raw)
To: avinash pawar; +Cc: linux-c-programming
On 8/1/05, avinash pawar <lkmails@gmail.com> wrote:
> Hello Everyone ,
>
> Can anyone of you please tell me..
>
> what does extern "C" int func(int *,foo) accomplish ?
>
When using existing C headers that already conform to ANSI C in C++
they need to be slightly modified to enable proper linkage for the
language and to ensure that C++ keywords are not used as identifiers.
This means that you can use C headers in C++ projects in the following way:
#ifdef __cplusplus
extern "C" {
#endif
...
int func(int *,foo);
...
#ifdef __cplusplus
}
#endif
Code placed between the two ifdefs is either linked as C or C++. The
__cplusplus macro is usually predefined in appropriate system headers.
To answer your question: when a routine will be called from another
language (here C is called from C++) it should be declared in C++ as
extern "C" int func(int *,foo);
The extern "C" causes the routine to have a so called 'unmangled' name
that can be refered to not only from C but also from Fortran or Cobol.
Without extern "C" the routine will get a link 'mangled' link name
like func__abc.
Regards
\Steve
--
Steve Graegert
Software Consultancy
Mobile: +49 (176) 21248869
Office: +49 (9131) 7126409
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Query in C
@ 2005-08-01 11:13 r_zaca
0 siblings, 0 replies; 3+ messages in thread
From: r_zaca @ 2005-08-01 11:13 UTC (permalink / raw)
To: linux-c-programming
[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 395 bytes --]
Hello Avinash,
This is a function that returns a "int value" and allows you to pass as
parameters two data types, an "int pointer" and a "foo data".
Well, I think it would be helpful.
That's it.
>Hello Everyone ,
>
> Can anyone of you please tell me..
>
> what does extern "C" int func(int *,foo) accomplish ?
>
> waiting for your reply.
>
>regards,
>Avinash
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-08-01 11:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-01 11:13 Query in C r_zaca
-- strict thread matches above, loose matches on Subject: below --
2005-07-15 22:35 Variable to sizeof function Steve Graegert
2005-07-16 6:44 ` Vikas S
2005-07-17 16:27 ` Vadiraj
2005-08-01 6:10 ` Query in C avinash pawar
2005-08-01 6:44 ` Steve Graegert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).