Dear all,
I wrote a small program prog1.cpp that cranks out the numbers in the sequence A016278 in OEIS
http://www.research.att.com/~njas/sequences/A016278
The program runs on slax, but fails to do so on rawhide.
[olivares@localhost Documents]$ cat prog1.cpp #include <iostream.h> #include <stdlib.h> #include <math.h>
int main(int argc, char *argv[]) { int i; double j; for (i=1; i < 16; i++) { j = (4.0/7.0)*pow(2.0,i-1)+(-3.0/2.0)*pow(3.0,i-1)+(27.0/14.0)*pow(9.0,i-1); cout << i << ' ' << j << "\n"; } return EXIT_SUCCESS; }
[olivares@localhost Documents]$ cat /etc/fedora-release Fedora release 8.93 (Rawhide) [olivares@localhost Documents]$ c++ -o prog1 prog1.cpp prog1.cpp:1:22: error: iostream.h: No such file or directory prog1.cpp: In function ‘int main(int, char**)’: prog1.cpp:13: error: ‘cout’ was not declared in this scope [olivares@localhost Documents]$
On slax 6.0.5/6.0.6 it runs fine although with some warnings:
root@slax:~# c++ -o prog1 prog1.cpp In file included from /usr/lib/gcc/i486-slackware-linux/4.2.3/../../../../include/c++/4.2.3/backward/iostream.h:31, from prog1.cpp:1: /usr/lib/gcc/i486-slackware-linux/4.2.3/../../../../include/c++/4.2.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. root@slax:~# ./prog1 1 1 2 14 3 145 4 1370 5 12541 6 113534 ....,
Is there something that needs to be done so that the program can compile fine in rawhide?
TIA,
Antonio
____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
On Tue, 2008-04-22 at 05:00 -0700, Antonio Olivares wrote:
Dear all,
I wrote a small program prog1.cpp that cranks out the numbers in the sequence A016278 in OEIS
http://www.research.att.com/~njas/sequences/A016278
The program runs on slax, but fails to do so on rawhide.
[olivares@localhost Documents]$ cat prog1.cpp #include <iostream.h> #include <stdlib.h> #include <math.h>
int main(int argc, char *argv[]) { int i; double j; for (i=1; i < 16; i++) { j = (4.0/7.0)*pow(2.0,i-1)+(-3.0/2.0)*pow(3.0,i-1)+(27.0/14.0)*pow(9.0,i-1); cout << i << ' ' << j << "\n"; } return EXIT_SUCCESS; }
[olivares@localhost Documents]$ cat /etc/fedora-release Fedora release 8.93 (Rawhide) [olivares@localhost Documents]$ c++ -o prog1 prog1.cpp prog1.cpp:1:22: error: iostream.h: No such file or directory prog1.cpp: In function ‘int main(int, char**)’: prog1.cpp:13: error: ‘cout’ was not declared in this scope [olivares@localhost Documents]$
On slax 6.0.5/6.0.6 it runs fine although with some warnings:
root@slax:~# c++ -o prog1 prog1.cpp In file included from /usr/lib/gcc/i486-slackware-linux/4.2.3/../../../../include/c++/4.2.3/backward/iostream.h:31, from prog1.cpp:1: /usr/lib/gcc/i486-slackware-linux/4.2.3/../../../../include/c++/4.2.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. root@slax:~# ./prog1 1 1 2 14 3 145 4 1370 5 12541 6 113534 ....,
Is there something that needs to be done so that the program can compile fine in rawhide?
TIA,
Antonio
I would take the .h off the includes and it appears the 'using namespace std;' line is missing? HTH...
-Jason
--- Jason jmtaylor90@gmail.com wrote:
On Tue, 2008-04-22 at 05:00 -0700, Antonio Olivares wrote:
Dear all,
I wrote a small program prog1.cpp that cranks out
the numbers in the sequence A016278 in OEIS
http://www.research.att.com/~njas/sequences/A016278
The program runs on slax, but fails to do so on
rawhide.
[olivares@localhost Documents]$ cat prog1.cpp #include <iostream.h> #include <stdlib.h> #include <math.h>
int main(int argc, char *argv[]) { int i; double j; for (i=1; i < 16; i++) { j =
(4.0/7.0)*pow(2.0,i-1)+(-3.0/2.0)*pow(3.0,i-1)+(27.0/14.0)*pow(9.0,i-1);
cout << i << ' ' << j << "\n";
} return EXIT_SUCCESS; }
[olivares@localhost Documents]$ cat
/etc/fedora-release
Fedora release 8.93 (Rawhide) [olivares@localhost Documents]$ c++ -o prog1
prog1.cpp
prog1.cpp:1:22: error: iostream.h: No such file or
directory
prog1.cpp: In function âint main(int,
char**)â:
prog1.cpp:13: error: âcoutâ was not declared
in this scope
[olivares@localhost Documents]$
On slax 6.0.5/6.0.6 it runs fine although with
some warnings:
root@slax:~# c++ -o prog1 prog1.cpp In file included from
/usr/lib/gcc/i486-slackware-linux/4.2.3/../../../../include/c++/4.2.3/backward/iostream.h:31,
from prog1.cpp:1:
/usr/lib/gcc/i486-slackware-linux/4.2.3/../../../../include/c++/4.2.3/backward/backward_warning.h:32:2:
warning: #warning This file includes at least one deprecated or antiquated header. Please consider
using
one of the 32 headers found in section 17.4.1.2 of
the
C++ standard. Examples include substituting the
<X> > header for the <X.h> header for C++ includes, or > <iostream> instead of the deprecated header > <iostream.h>. To disable this warning use > -Wno-deprecated. > root@slax:~# ./prog1 > 1 1 > 2 14 > 3 145 > 4 1370 > 5 12541 > 6 113534 > ...., > > Is there something that needs to be done so that the program can compile fine in rawhide? > > TIA, > > Antonio >
I would take the .h off the includes and it appears the 'using namespace std;' line is missing? HTH...
-Jason
--
fedora-test-list mailing list fedora-test-list@redhat.com To unsubscribe:
https://www.redhat.com/mailman/listinfo/fedora-test-list
Thanks Jason,
but it still does not work :(
[rio@localhost Documents]$ cat prog1.cpp using namespace std; #include <iostream> #include <stdlib> #include <math>
int main(int argc, char *argv[]) { int i; double j; for (i=1; i < 7; i++) { j = (4.0/7.0)*pow(2.0,i-1)+(-3.0/2.0)*pow(3.0,i-1)+(27.0/14.0)*pow(9.0,i-1); cout << i << ' ' << j << "\n"; } return EXIT_SUCCESS; }
[rio@localhost Documents]$ c++ -o prog1 prog1.cpp prog1.cpp:3:18: error: stdlib: No such file or directory prog1.cpp:4:16: error: math: No such file or directory prog1.cpp: In function ‘int main(int, char**)’: prog1.cpp:12: error: ‘pow’ was not declared in this scope prog1.cpp:15: error: ‘EXIT_SUCCESS’ was not declared in this scope [rio@localhost Documents]$
If i move
it down before main declaration, still fails with
[rio@localhost Documents]$ c++ -o prog1 prog1.cpp prog1.cpp:2:18: error: stdlib: No such file or directory prog1.cpp:3:16: error: math: No such file or directory prog1.cpp: In function ‘int main(int, char**)’: prog1.cpp:12: error: ‘pow’ was not declared in this scope prog1.cpp:15: error: ‘EXIT_SUCCESS’ was not declared in this scope
TIA,
Antonio
____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
On Tue, 22 Apr 2008 05:00:20 -0700 (PDT), Antonio Olivares wrote:
Dear all,
I wrote a small program prog1.cpp that cranks out the numbers in the sequence A016278 in OEIS
http://www.research.att.com/~njas/sequences/A016278
The program runs on slax, but fails to do so on rawhide.
[olivares@localhost Documents]$ cat prog1.cpp #include <iostream.h> #include <stdlib.h> #include <math.h>
int main(int argc, char *argv[]) { int i; double j; for (i=1; i < 16; i++) { j = (4.0/7.0)*pow(2.0,i-1)+(-3.0/2.0)*pow(3.0,i-1)+(27.0/14.0)*pow(9.0,i-1); cout << i << ' ' << j << "\n"; } return EXIT_SUCCESS; }
[olivares@localhost Documents]$ cat /etc/fedora-release Fedora release 8.93 (Rawhide) [olivares@localhost Documents]$ c++ -o prog1 prog1.cpp prog1.cpp:1:22: error: iostream.h: No such file or directory prog1.cpp: In function ‘int main(int, char**)’: prog1.cpp:13: error: ‘cout’ was not declared in this scope [olivares@localhost Documents]$
Is there something that needs to be done so that the program can compile fine in rawhide?
Make it C++. Include <iostream>, <cstdlib>, <cmath>. Consider the namespaces, e.g. cout is std::cout in global scope. Use ios::endl not '\n'. Declare i inside the for-statement. Declare j inside the for-loop body. Then it comes closer to C++.
--- Michael Schwendt mschwendt.tmp0701.nospam@arcor.de wrote:
On Tue, 22 Apr 2008 05:00:20 -0700 (PDT), Antonio Olivares wrote:
Dear all,
I wrote a small program prog1.cpp that cranks out
the numbers in the sequence A016278 in OEIS
http://www.research.att.com/~njas/sequences/A016278
The program runs on slax, but fails to do so on
rawhide.
[olivares@localhost Documents]$ cat prog1.cpp #include <iostream.h> #include <stdlib.h> #include <math.h>
int main(int argc, char *argv[]) { int i; double j; for (i=1; i < 16; i++) { j =
(4.0/7.0)*pow(2.0,i-1)+(-3.0/2.0)*pow(3.0,i-1)+(27.0/14.0)*pow(9.0,i-1);
cout << i << ' ' << j << "\n";
} return EXIT_SUCCESS; }
[olivares@localhost Documents]$ cat
/etc/fedora-release
Fedora release 8.93 (Rawhide) [olivares@localhost Documents]$ c++ -o prog1
prog1.cpp
prog1.cpp:1:22: error: iostream.h: No such file or
directory
prog1.cpp: In function âint main(int,
char**)â:
prog1.cpp:13: error: âcoutâ was not declared
in this scope
[olivares@localhost Documents]$
Is there something that needs to be done so that
the program can compile fine in rawhide?
Make it C++. Include <iostream>, <cstdlib>, <cmath>. Consider the namespaces, e.g. cout is std::cout in global scope. Use ios::endl not '\n'. Declare i inside the for-statement. Declare j inside the for-loop body. Then it comes closer to C++.
-- fedora-test-list mailing list fedora-test-list@redhat.com To unsubscribe:
https://www.redhat.com/mailman/listinfo/fedora-test-list
If I use ios::endl, the program fails,
[rio@localhost Documents]$ cat prog2.cpp #include <iostream> #include <cstdlib> #include <cmath> using namespace std;
int main(int argc, char *argv[]) { for (int i=1; i < 7; i++) { double j; j = (4.0/7.0)*pow(2.0,i-1)+(-3.0/2.0)*pow(3.0,i-1)+(27.0/14.0)*pow(9.0,i-1); std::cout << i << ' ' << j << ios::endl; } return EXIT_SUCCESS; }
[rio@localhost Documents]$ c++ -o prog2 prog2.cpp prog2.cpp: In function ‘int main(int, char**)’: prog2.cpp:12: error: ‘endl’ is not a member of ‘std::ios’
but if I remove the ios:: part and leave endl; it works :)
[rio@localhost Documents]$ c++ -o prog2 prog2.cpp [rio@localhost Documents]$ ./prog2 1 1 2 14 3 145 4 1370 5 12541 6 113534 [rio@localhost Documents]$
Thank you very much Michael, that was what was needed. I appreciate yours and Jason's help. Now the program compiles on Fedora as well.
Regards,
Antonio
____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ