0

I have a code including

#include <iostream>
#include <iomanip>
#include <fstream>

using namespace std;

And it works with MinGW under XP.
I want to compile the same code under Suse linux,
but compiler said that for example:
atof(), error() functions are not defined.

The problem solved if I include

#include <stdio.h>
#include <stdlib.h>

also, but I don't understand!
The packages are different under XP and linux?
I want a platform independent code.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Narue
0

The packages are different under XP and linux?

No. Your code under Windows was benefiting from internal includes. That is, standard headers themselves include other standard headers, which means somewhere in <iostream>, for example, <cstdlib> was included. atof is declared in <cstdlib>, so your calls magically worked.

It's best to include all of the headers you need, even if the code still compiles without them. Of course, this also means you should know which header to include for all of the standard names you use. ;)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.