473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

difference between stdio.h and cstdio

My understanding is that cstdio basically is the same as stdio.h except
the functions are in a namspace called std. However when I take a look
at the content of the file cstdio, it has the following lines inside
only:

-------content of cstdio on red hat linux enterprise 3----
#ifndef __CSTDIO__
#define __CSTDIO__
#include <stdio.h>
#endif
---------------------------------------

I did not see anywhere or how these functions are defined in namespace
std, looks like it merely include c language 's stdio.h. Can anyone
give me an explanation why on linux (maybe on other boxes too) I did
not see why cstdio's functions are defined in std namespace?

Thanks,

David

Dec 6 '06 #1
2 14566
david wolf wrote:
My understanding is that cstdio basically is the same as stdio.h except
the functions are in a namspace called std. However when I take a look
at the content of the file cstdio, it has the following lines inside
only:

-------content of cstdio on red hat linux enterprise 3----
#ifndef __CSTDIO__
#define __CSTDIO__
#include <stdio.h>
#endif
---------------------------------------

I did not see anywhere or how these functions are defined in namespace
std, looks like it merely include c language 's stdio.h. Can anyone
give me an explanation why on linux (maybe on other boxes too) I did
not see why cstdio's functions are defined in std namespace?

Thanks,

David
On my gcc 4.0.2 this is not the case.
Have you loooked in stdio.h?

Sincerely,

Peter Jansson
http://www.p-jansson.com/
http://www.jansson.net/
Dec 6 '06 #2
david wolf wrote:
My understanding is that cstdio basically is the same as stdio.h except
the functions are in a namspace called std. However when I take a look
at the content of the file cstdio, it has the following lines inside
only:

-------content of cstdio on red hat linux enterprise 3----
#ifndef __CSTDIO__
#define __CSTDIO__
#include <stdio.h>
#endif
---------------------------------------

I did not see anywhere or how these functions are defined in namespace
std, looks like it merely include c language 's stdio.h. Can anyone
give me an explanation why on linux (maybe on other boxes too) I did
not see why cstdio's functions are defined in std namespace?
This question should probably be directed to a GCC support list.

I have gcc v 4.1.1 on fedora and cstdio looks nothing like that.

Here it is:

// -*- C++ -*- forwarding header.

// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301,
// USA.

// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you
compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.

//
// ISO C++ 14882: 27.8.2 C Library files
//

/** @file cstdio
* This is a Standard C++ Library file. You should @c #include this file
* in your programs, rather than any of the "*.h" implementation files.
*
* This is the C++ version of the Standard C Library header @c stdio.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/

#ifndef _GLIBCXX_CSTDIO
#define _GLIBCXX_CSTDIO 1

#pragma GCC system_header

#include <bits/c++config.h>
#include <cstddef>

#include <stdio.h>

// Get rid of those macros defined in <stdio.hin lieu of real functions.
#undef clearerr
#undef fclose
#undef feof
#undef ferror
#undef fflush
#undef fgetc
#undef fgetpos
#undef fgets
#undef fopen
#undef fprintf
#undef fputc
#undef fputs
#undef fread
#undef freopen
#undef fscanf
#undef fseek
#undef fsetpos
#undef ftell
#undef fwrite
#undef getc
#undef getchar
#undef gets
#undef perror
#undef printf
#undef putc
#undef putchar
#undef puts
#undef remove
#undef rename
#undef rewind
#undef scanf
#undef setbuf
#undef setvbuf
#undef sprintf
#undef sscanf
#undef tmpfile
#undef tmpnam
#undef ungetc
#undef vfprintf
#undef vprintf
#undef vsprintf

namespace std
{
using ::FILE;
using ::fpos_t;

using ::clearerr;
using ::fclose;
using ::feof;
using ::ferror;
using ::fflush;
using ::fgetc;
using ::fgetpos;
using ::fgets;
using ::fopen;
using ::fprintf;
using ::fputc;
using ::fputs;
using ::fread;
using ::freopen;
using ::fscanf;
using ::fseek;
using ::fsetpos;
using ::ftell;
using ::fwrite;
using ::getc;
using ::getchar;
using ::gets;
using ::perror;
using ::printf;
using ::putc;
using ::putchar;
using ::puts;
using ::remove;
using ::rename;
using ::rewind;
using ::scanf;
using ::setbuf;
using ::setvbuf;
using ::sprintf;
using ::sscanf;
using ::tmpfile;
using ::tmpnam;
using ::ungetc;
using ::vfprintf;
using ::vprintf;
using ::vsprintf;
}

#if _GLIBCXX_USE_C9 9

#undef snprintf
#undef vfscanf
#undef vscanf
#undef vsnprintf
#undef vsscanf

namespace __gnu_cxx
{
#if _GLIBCXX_USE_C9 9_CHECK || _GLIBCXX_USE_C9 9_DYNAMIC
extern "C" int
(snprintf)(char * restrict, size_t, const char * restrict, ...);
extern "C" int
(vfscanf)(FILE * restrict, const char * restrict, __gnuc_va_list) ;
extern "C" int (vscanf)(const char * restrict, __gnuc_va_list) ;
extern "C" int
(vsnprintf)(cha r * restrict, size_t, const char * restrict,
__gnuc_va_list) ;
extern "C" int
(vsscanf)(const char * restrict, const char * restrict, __gnuc_va_list) ;
#endif

#if !_GLIBCXX_USE_C 99_DYNAMIC
using ::snprintf;
using ::vfscanf;
using ::vscanf;
using ::vsnprintf;
using ::vsscanf;
#endif
}

namespace std
{
using __gnu_cxx::snpr intf;
using __gnu_cxx::vfsc anf;
using __gnu_cxx::vsca nf;
using __gnu_cxx::vsnp rintf;
using __gnu_cxx::vssc anf;
}
#endif

#endif
Dec 6 '06 #3

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

Similar topics

20
5520
by: Mark | last post by:
I am using gnu g++ version 3.3.2, trying a simple test to read in and then write out a large (100,000 line) text file ########################################## CSTDIO VERSION TO READ/WRITE TEXT FILE: #include <cstdlib> #include <cstdio> using namespace std;
5
2282
by: John Douglass | last post by:
I'm fairly new to doing involved file i/o and I came across something weird with a program I'm writing (modifying MIDI data, if it makes any difference). With some input files, when I modify data and then output to a new file, the program will crash. The catch is that when I open up the output file to see what the program managed to write, it always makes it to an offset of xFFF. For example, with one file it crashed at 2FFF, another at...
0
2655
by: JW | last post by:
I'm using MSVC7.0 and I'm getting a ton of errors with most of them occurring in cstdio. Any thoughts as to what might cause this? d:\Program Files\Microsoft Visual Studio .NET\Vc7 \PlatformSDK\Include\Guiddef.h(161) : error C2065: 'memcmp' : undeclared identifier d:\Program Files\Microsoft Visual Studio .NET\Vc7
4
17072
by: Chad | last post by:
What purpose does __THROW serve in stdio.h. For example, in I see stuff like the following in stdio.h: /* Generate a temporary filename. */ extern char *tmpnam (char *__s) __THROW; __END_NAMESPACE_STD #ifdef __USE_MISC /* This is the reentrant variant of `tmpnam'. The only difference is that it does not allow S to be NULL. */
3
2192
by: streamkid | last post by:
hello.. my code is this: //test.cpp #include <cstdio> int main(void) { int NP; char *tmp; FILE *fin;
23
3649
by: Jess | last post by:
Hello, I understand the default-initialization happens if we don't initialize an object explicitly. I think for an object of a class type, the value is determined by the constructor, and for the built-in types, the value is usually garbage. Is this right? However, I'm a bit confused about value-initialization, when does it happen, and what kind of values are assigned to objects?
34
19862
by: Mark Sullivan | last post by:
What is the difference between the extensions *.hxx and just *.h for header files ? Can they co-exist? Mark
5
1509
by: Rainer Heynke | last post by:
Hi, a friend of mine ask about the reason and the history beyond the two different ways to include std-headers like #include "stdio.h" #include <cstdio> He's no using the usenet, but he read the answers via google.
11
5133
by: sunnyalways4u2000 | last post by:
hello sir, Sir will please tell me the exact difference between C and advanced C...what are the extra features or funcions...etc added in this advanced one.
0
8339
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,...
0
8751
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 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...
1
8535
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,...
0
8629
tracyyun
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...
0
7360
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, 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...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
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...
0
4338
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2757
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 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.