For code that was part of the C library, being used in C++, should you
always prefix std::
Specific examples:
std::fopen
std::fclose
std::atexit
Should I include
<cstdio> or <cstdlib>?
g++ 3.4.2 in mingw doesn't seem to care one way or the other. No
warnings or errors are produced even with -W -Wall.
Thanks,
--John Ratliff 5 1397
John Ratliff wrote: For code that was part of the C library, being used in C++, should you always prefix std::
Specific examples:
std::fopen std::fclose std::atexit
Should I include
<cstdio> or <cstdlib>?
g++ 3.4.2 in mingw doesn't seem to care one way or the other. No warnings or errors are produced even with -W -Wall.
One probably includes the other.
Ian
>> Should I include
<cstdio> or <cstdlib>?
g++ 3.4.2 in mingw doesn't seem to care one way or the other. No warnings or errors are produced even with -W -Wall. One probably includes the other.
Ian
Sorry, my post was unclear.
I meant should I include cstdio for std::fclose/std::fopen/std::freopen
and should I include cstdlib for std::atexit.
I wasn't including either, and still no warnings. I was including
iostream, vector, and stdexcept.
--John Ratliff
John Ratliff wrote:
<snip> I wasn't including either, and still no warnings. I was including iostream, vector, and stdexcept.
<snip>
In C++, unlike in C, the standard doesn't specify which
header files include each other. So always err on the
safe side and include headers for all functions/classes
you use in a translation unit. Specifically, don't rely
on <iostream> including <cstdio>.
Marc
In message <2dfPe.64649$084.1631@attbi_s22>, John Ratliff
<us**@example.net> writes For code that was part of the C library, being used in C++, should you always prefix std::
Assuming you're using #include <cxxx> rather than #include <xxx.h>, you
*should*, but some implementations hoist those declarations into the
global namespace willy-nilly, so you might get away without the prefix.
But the first time you try to compile using something that doesn't,
you're in for a lot of editing :-( Specific examples:
std::fopen std::fclose std::atexit
Should I include
<cstdio> or <cstdlib>?
You *should* include both, but in some implementations one will include
the other in any case. Again, you can't rely on this.
g++ 3.4.2 in mingw doesn't seem to care one way or the other. No warnings or errors are produced even with -W -Wall.
--
Richard Herring
Richard Herring wrote: In message <2dfPe.64649$084.1631@attbi_s22>, John Ratliff <us**@example.net> writes
For code that was part of the C library, being used in C++, should you always prefix std::
Assuming you're using #include <cxxx> rather than #include <xxx.h>, you *should*, but some implementations hoist those declarations into the global namespace willy-nilly, so you might get away without the prefix. But the first time you try to compile using something that doesn't, you're in for a lot of editing :-(
Specific examples:
std::fopen std::fclose std::atexit
Should I include
<cstdio> or <cstdlib>?
You *should* include both, but in some implementations one will include the other in any case. Again, you can't rely on this.
g++ 3.4.2 in mingw doesn't seem to care one way or the other. No warnings or errors are produced even with -W -Wall.
Thanks, I've done both. And yes, I don't want to rely on any specific
implementation.
--John Ratliff This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Simon |
last post by:
Hello.
I wanna use my dynamic shared library(built with C language) with php
script.
(PHP version is 4.0.6)
So I making a shared library(*.so) in Solaris environment(2.7) and it is
successful....
|
by: Raymond Hettinger |
last post by:
Comments are invited on the following proposed PEP.
Raymond Hettinger
-------------------------------------------------------
PEP: 329
|
by: K.S.Liang |
last post by:
Hi all,
1> If there are more than one dynamic linking libraries in the file
system, how do I know which one is loaded into system? Any C library
or system call can tell me which *.so or *.sl is...
|
by: Jim |
last post by:
Have fully operational software package developed on VB.NET that worked until Jan 1 2003, with early stage deployments on Oct 10, Oct 23, Nov 11, Dec 12 and Dec 30.
When attempted final...
|
by: Julian |
last post by:
I get the following error when i try to link a fortran library to a c++ code
in .NET 2005.
LINK : fatal error LNK1104: cannot open file 'libc.lib'
the code was working fine when built using...
|
by: Chris F Clark |
last post by:
Please excuse the length of this post, I am unfortunately long-winded,
and don't know how to make my postings more brief.
I have a C++ class library (and application generator, called
Yacc++(r)...
|
by: Robert Seacord |
last post by:
The SEI has published CMU/SEI-2006-TR-006 "Specifications for Managed
Strings" and released a "proof-of-concept" implementation of the managed
string library.
The specification, source code for...
|
by: Frank-O |
last post by:
Hi ,
Recently I have been commited to the task of "translating" some complex
statistical algorithms from Matlab to C++. The goal is to be three
times as fast as matlab ( the latest) .
I've...
|
by: JosAH |
last post by:
Greetings,
the last two article parts described the design and implementation of the
text Processor which spoonfeeds paragraphs of text to the LibraryBuilder.
The latter object organizes, cleans...
|
by: JosAH |
last post by:
Greetings,
welcome back; above we discussed the peripherals of the Library class: loading
and saving such an instantiation of it, the BookMark interface and then some.
This part of the article...
|
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |