www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/10/17/17:30:23

From: Nate Eldredge <neldredge AT hmc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: #ifdef __cplusplus
Date: 17 Oct 2000 14:19:49 -0700
Organization: InterWorld Communications
Lines: 24
Sender: nate AT mercury DOT st DOT hmc DOT edu
Message-ID: <83u2ab413e.fsf@mercury.st.hmc.edu>
References: <F13H5.1850$AV6 DOT 115584 AT news DOT chello DOT at>
NNTP-Posting-Host: mercury.st.hmc.edu
Mime-Version: 1.0
X-Trace: nntp1.interworld.net 971817589 60456 134.173.57.219 (17 Oct 2000 21:19:49 GMT)
X-Complaints-To: usenet AT news DOT interworld DOT net
NNTP-Posting-Date: Tue, 17 Oct 2000 21:19:49 +0000 (UTC)
User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.5
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Kurt Aistinger" <kurt DOT aistinger AT chello DOT at> writes:

> Hi!
> I recently read through the stdio.h and discovered following lines:
> at the beginning it says:
>             #ifdef __cplusplus
>                 extern "C" {
>             #endif
> and at the end:
>             #ifdef __cplusplus
>                 }
>             #endif
> Could anyone explain to me what this is good for?

This is so stdio.h can be used by either C or C++ programs.  In a C++
program, declarations of functions written in C (like those in
stdio.h) need to be enclosed in `extern "C" { }'.  So these lines have
the effect of enclosing the entire header in those braces when the C++
compiler is in use.

-- 

Nate Eldredge
neldredge AT hmc DOT edu

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019