What's that preprocessor do
#ifdef __cplusplus
extern "C" {
#endif
..
..
..
#ifdef __cplusplus
}
#endif
and how you say extern "C" , i mean how u extern constant!! 5 2928
"Medvedev" <3D********@gma il.comwrote in message
news:7f******** *************** ***********@t54 g2000hsg.google groups.com...
What's that preprocessor do
#ifdef __cplusplus
extern "C" {
#endif
.
.
.
#ifdef __cplusplus
}
#endif
and how you say extern "C" , i mean how u extern constant!!
extern "C"
{
}
... causes any functions inside the braces to have
"C linkage", so that they can be called from C
functions. There's nothing about 'constant' here.
The #ifdef will cause 'extern C' to be applied only
if translating C++ code.
-Mike
On Jul 6, 2:12 pm, "Mike Wahler" <mkwah...@mkwah ler.netwrote:
"Medvedev" <3D.v.Wo...@gma il.comwrote in message
news:7f******** *************** ***********@t54 g2000hsg.google groups.com...
What's that preprocessor do
#ifdef __cplusplus
extern "C" {
#endif
.
.
.
#ifdef __cplusplus
}
#endif
and how you say extern "C" , i mean how u extern constant!!
extern "C"
{
}
.. causes any functions inside the braces to have
"C linkage", so that they can be called from C
functions. There's nothing about 'constant' here.
sorry , but what differ C++ functions from C ones
"Medvedev" <3D********@gma il.comwrote in message
news:ce******** *************** ***********@e53 g2000hsa.google groups.com...
On Jul 6, 2:12 pm, "Mike Wahler" <mkwah...@mkwah ler.netwrote:
>"Medvedev" <3D.v.Wo...@gma il.comwrote in message
news:7f******* *************** ************@t5 4g2000hsg.googl egroups.com...
What's that preprocessor do
#ifdef __cplusplus
extern "C" {
#endif
.
.
.
#ifdef __cplusplus
}
#endif
and how you say extern "C" , i mean how u extern constant!!
extern "C" {
}
.. causes any functions inside the braces to have "C linkage", so that they can be called from C functions. There's nothing about 'constant' here.
sorry , but what differ C++ functions from C ones
C++ functions have overloading. C functions do not. This means there is
only one definition for a C function, there can be more than one for a C++
function. Compilers typcially handle this by "mangling". This will change
the name of the C++ function in the object file so the linker can
differentiate between calling parameters.
stating:
extern "C" {
tells the compiler not to mangle the function names, there will only be one
declaration for each function, so then when it is linked it has C linkage,
the function name would be the same as if it was a C function, and C
programs/objects can call the function as they can now link to them.
"Medvedev" <3D********@gma il.comwrote in message
news:ce******** *************** ***********@e53 g2000hsa.google groups.com...
On Jul 6, 2:12 pm, "Mike Wahler" <mkwah...@mkwah ler.netwrote:
>"Medvedev" <3D.v.Wo...@gma il.comwrote in message
news:7f******* *************** ************@t5 4g2000hsg.googl egroups.com...
What's that preprocessor do
#ifdef __cplusplus
extern "C" {
#endif
.
.
.
#ifdef __cplusplus
}
#endif
and how you say extern "C" , i mean how u extern constant!!
extern "C" {
}
.. causes any functions inside the braces to have "C linkage", so that they can be called from C functions. There's nothing about 'constant' here.
sorry , but what differ C++ functions from C ones
Think about overloading. You can have more than a
single function with the same name (the number and/or
types of arguments would differ.
int foo(void);
int foo(int);
int foo(int,int);
C++ needs to distinguish these functions from one another.
There's no specific method required by the standard, but
typically the compiler will 'mangle' the names (change and/or
add characters) so that they become unique.
"extern C" prevents this 'mangling', so that the function
can be linked with C (using its 'real' name).
Anyway, I should have already cited this link from the C++ FAQ: http://www.parashift.com/c++-faq-lit...c-and-cpp.html
This explains it better than I.
-Mike
On Jul 7, 12:18 am, Medvedev <3D.v.Wo...@gma il.comwrote:
On Jul 6, 2:12 pm, "Mike Wahler" <mkwah...@mkwah ler.netwrote:
"Medvedev" <3D.v.Wo...@gma il.comwrote in message
news:7f******** *************** ***********@t54 g2000hsg.google groups.com....
What's that preprocessor do
#ifdef __cplusplus
extern "C" {
#endif
.
.
.
#ifdef __cplusplus
}
#endif
and how you say extern "C" , i mean how u extern constant!!
extern "C"
{
}
.. causes any functions inside the braces to have
"C linkage", so that they can be called from C
functions. There's nothing about 'constant' here.
sorry , but what differ C++ functions from C ones
Whatever the implementation wants. There's no fundamental
reason for two different languages to use the same calling
conventions. One typical difference might be that in C++, the
call stack is cleaned up in the called function (since it
involves calling destructors, etc.), where as in C, it is
cleaned up in the callee (since historically, C didn't have
prototypes, and allowed calling a function with extra arguments,
which were ignored). Also, C++ has overloading, which means
that some sort of information concerning the type and number of
arguments must be maintained in the object file. And because C
allowed extra arguments, a C compiler will not want to do this.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: terrencel |
last post by:
I was told to look at some old C code that was ported to C++.
One of the file is like:
=========================================
CPPClass* someCPPVar = NULL;
extern "C"
{
|
by: Daniele Benegiamo |
last post by:
Is the following program standard-compliant? I've compiled it with some
compilers and no errors or warnings are produced, but this is not a
demonstration.
The "incriminated" part is the declaration:
extern "C" struct X;
that is then defined as:
|
by: Mark A. Gibbs |
last post by:
I have a question about mixing C and C++.
In a C++ translation unit, I want to define a function with internal
linkage and C calling convention. Here's a sample of what I want to do:
// main.cpp
// This is defined in a C module
extern "C" void fake_qsort(void*, std::size_t, std::size_t,
int (*compare)(const void*, const void*));
|
by: Vijay Kumar Zanvar |
last post by:
Hello
I have seen in many source files the usage of extern +ACI-C+ACI-.
What is its purpose?
Thanks
VRZ
|
by: G Patel |
last post by:
I've seen some code with extern modifiers in front of variables
declared inside blocks. Are these purely definitions (no definition)
or are they definitions with static duration but external linkage?
Not much on this in the FAQ or tutorials.
| |
by: ccwork |
last post by:
Hi all,
I am reading "C: A Reference Manual" 4th ed and I get lost for the
"extern". It says that global object without specifying the
storage-class specifier will have "extern" as the default storage-class
specifier. My (little) C experience tells me that an object with
"extern" is to let the linker knows that the object is referencing the
object defined in somewhere, and this "somewhere" object does not have
the storage-class specifier...
|
by: jchludzinski |
last post by:
I have 3 files (see below: a.h, w.c, ww.c). I would like to use a
single x (declared somewhere) which would global to both compilation
units: w.c & ww.c. No matter where I place the "extern" qualifier - it
appears to work: x is shared between w.c and ww.c. Or if I simple
don't use "extern", it works. Why? What is the correct (or simply
preferred) usage?
---John
PSI'm using gcc (GCC) 4.0.2.
|
by: Christoph Conrad |
last post by:
Hi,
given the following test case, with CString from Microsofts MFC:
==================================================
file 1:
CString arr;
==================================================
|
by: mimi |
last post by:
The programmer indicates to the compiler that a function is written
in a different programming language using a linkage directives.It is
intuitive that extern "SomeLanguage" is used to declare functions
written in the "SomeLanguage".
But I am quite confused what information does the linkage directive
tells the compiler.The "generated" function name? The way the
arguments are ordered?Or something else?
And I am still wondering why extern...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |