Hello, I know what ifdef is used for, but I am not sure what these
lines are for for compilation.
#ifdef __cplusplus
extern "C" {
#endif
Thanks a lot! 9 1514
In article <11**********************@g14g2000cwa.googlegroups .com>,
<po***********@gmail.com> wrote: Hello, I know what ifdef is used for, but I am not sure what these lines are for for compilation.
#ifdef __cplusplus extern "C" { #endif
Those lines are for use with C++. Parts of C++ are close enough to
parts of C to make it practical to use the C code within C++, except
that C++ has to be told to that the C code will be using C calling
conventions instead of C++ calling conventions. The #if you show
will have no effect on the code when processed by a C compiler, but
when processed by a C++ compiler then __cplusplus will be true,
causing extern "C" { } to be placed around the entire block of C
code -- which is the necessary signal to C++ about the calling conventions.
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers po***********@gmail.com wrote: Hello, I know what ifdef is used for, but I am not sure what these lines are for for compilation.
#ifdef __cplusplus extern "C" { #endif
Note that there will be a corresponding
#ifdef __cplusplus
}
#endif
somewhere further down the file.
This tells a C++ compiler that the following is C code, rather than C++.
If you need more information on how this works, you'll need to ask over
in comp.lang.c++ rather than here.
--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Kenneth Brody <ke******@spamcop.net> writes: po***********@gmail.com wrote: Hello, I know what ifdef is used for, but I am not sure what these lines are for for compilation.
#ifdef __cplusplus extern "C" { #endif Note that there will be a corresponding
#ifdef __cplusplus } #endif
somewhere further down the file.
This tells a C++ compiler that the following is C code, rather than C++.
I don't think that's *quite* accurate. As I understand it, the code
is still C++ (it's being processed by a C++ compiler, after all); for
example, it can't use "class" as an ordinary identifier.
If you need more information on how this works, you'll need to ask over in comp.lang.c++ rather than here.
Indeed -- but first check the comp.lang.c++ FAQ and/or any decent C++
textbook.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Kenneth Brody wrote: po***********@gmail.com wrote: Hello, I know what ifdef is used for, but I am not sure what these lines are for for compilation.
#ifdef __cplusplus extern "C" { #endif
This tells a C++ compiler that the following is C code, rather than C++.
Actually it doesn't. If you are using a C compiler, the code will
be treated as C, and if you are using a C++ compiler, the code
will be treated as C++.
This directive tells a C++ compiler to generate code that's
compatible with its C ABI, so that C and C++ object files can
subsequently be linked together. Examples of this include
disabling name mangling, and maybe different calling
conventions and structure padding.
Finally, nothing in the C standard prevents a C compiler from
defining __cplusplus, although only the DS9000 would do so.
I've attempted to set follow-ups to comp.lang.c++, because this
stuff is all part of C++ rather than C. I haven't done this before
so I hope it turns out well...
On 2005-12-05, Old Wolf <ol*****@inspire.net.nz> wrote: Finally, nothing in the C standard prevents a C compiler from defining __cplusplus, although only the DS9000 would do so.
6.10.8 p5
|The implementation shall not predefine the macro __cplusplus, nor shall
|it define it in any standard header.
I've attempted to set follow-ups to comp.lang.c++, because this stuff is all part of C++ rather than C. I haven't done this before so I hope it turns out well...
It did, but I chose to ignore it because I'm replying to an aspect of
your post that only applies to C.
"Old Wolf" <ol*****@inspire.net.nz> writes:
[...] Finally, nothing in the C standard prevents a C compiler from defining __cplusplus, although only the DS9000 would do so.
Unless you count C99 6.10.7p5:
The implementation shall not predefine the macro __cplusplus, nor
shall it define it in any standard header.
(An aside: when I did a copy-and-paste from n1124.pdf, the macro name
showed up as "_ _cplusplus", which might make it difficult to find; I
searched for just "cplusplus".)
I've attempted to set follow-ups to comp.lang.c++, because this stuff is all part of C++ rather than C. I haven't done this before so I hope it turns out well...
It did, but I overrode the "Followup-To:" header for this article.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Old Wolf wrote On 12/05/05 17:12,: [...] Finally, nothing in the C standard prevents a C compiler from defining __cplusplus, although only the DS9000 would do so.
Section 6.10.8, paragraph 5:
The implementation shall not predefine the
macro __cplusplus, nor shall it define it in
any standard header.
I've attempted to set follow-ups to comp.lang.c++, [...]
You did it correctly, but I added c.l.c. back
because the misteak should not stand unchallenged.
-- Er*********@sun.com
Eric Sosman wrote: misteak
.... so now I'm still hungry.
;)
--
pete
On Mon, 05 Dec 2005 22:49:43 GMT, in comp.lang.c , Keith Thompson
<ks***@mib.org> wrote: "Old Wolf" <ol*****@inspire.net.nz> writes: [...] Finally, nothing in the C standard prevents a C compiler from defining __cplusplus, although only the DS9000 would do so.
Unless you count C99 6.10.7p5:
The implementation shall not predefine the macro __cplusplus, nor shall it define it in any standard header.
(An aside: when I did a copy-and-paste from n1124.pdf, the macro name showed up as "_ _cplusplus", which might make it difficult to find; I searched for just "cplusplus".)
I've attempted to set follow-ups to comp.lang.c++, because this stuff is all part of C++ rather than C. I haven't done this before so I hope it turns out well...
It did, but I overrode the "Followup-To:" header for this article.
Is there an echo in here?
:-)
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =---- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: thecrow |
last post by:
Alright, what the hell is going on here?
In the following code, I expect the printed result to be:
DEBUG: frank's last name is burns.
Instead, what I get is:
DEBUG: frank's last name is...
|
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have...
|
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro...
|
by: Reed L. O'Brien |
last post by:
I see rotor was removed for 2.4 and the docs say use an AES module
provided separately... Is there a standard module that works alike or
an AES module that works alike but with better encryption?...
|
by: Philippe C. Martin |
last post by:
I apologize in advance for launching this post but I might get enlightment
somehow (PS: I am _very_ agnostic ;-).
- 1) I do not consider my intelligence/education above average
- 2) I am very...
|
by: Dario |
last post by:
The following simple program behaves differently
in Windows and Linux .
#include <stdexcept>
#include <iostream>
#include <string>
using namespace std;
class LogicError : public logic_error {...
|
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from...
|
by: Neal |
last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog
entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A
quite good article.
|
by: typingcat |
last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so
on. I've tried many PHP IDEs today, but almost non of them supported
Unicode (UTF-8) file.
I've found that the only Unicode...
|
by: Midnight Java Junkie |
last post by:
Dear Colleagues:
I feel that the dumbest questions are those that are never asked. I have
been given the opportunity to get into .NET. Our organization has a
subscription with Microsoft that...
|
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...
|
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: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |