compile problem

B

Bruce

I don't know why it didn't compile with gcc
in cygwin. If I change cout to std::cout,
I got more errors .... could this be namespace
issue, or maybe setting in cygwin ? or maybe
some careless mistake ?

Pls help, thanks !


#include <iostream>
#include <iomanip>

int main()
{

cout << "test" ;

return 0;
}
 
K

Kevin Goodsell

Bruce said:
I don't know why it didn't compile with gcc
in cygwin. If I change cout to std::cout,
I got more errors .... could this be namespace
issue, or maybe setting in cygwin ? or maybe
some careless mistake ?

Pls help, thanks !


#include <iostream>
#include <iomanip>

This is not used in your program.
int main()
{

cout << "test" ;

This needs to be std::cout. Also, you should terminate all text streams
with a newline for reliable output.
return 0;
}

Aside from that, there's nothing obviously wrong. Most likely your
compiler is either not installed correctly, or you invoked it
incorrectly. For more help on that you should consult a group that
discusses Cygwin or gcc. I'll offer a quick suggestion, though. Invoke
your compiler with the following command line:

g++ -W -Wall -ansi -pedantic -o output_file input_file.cpp

-Kevin
 
J

John Harrison

Bruce said:
I don't know why it didn't compile with gcc
in cygwin. If I change cout to std::cout,

It should be std::cout.

Apart from that it's correct, it would obviously help us to help you if you
posted the error messages.

john
 
T

Till Crueger

I don't know why it didn't compile with gcc in cygwin.

did you use the c++ compiler from gcc (gnu compiler collection) or the the
command gcc (gnu c compiler)? If you used the c compiler you should know
that it doesn't understand c++. You should use the command g++, which is
also part of gcc (compiler collection). The naming of gcc and gcc is very
confusing sometimes.

[snip correct program]

Don`t see anything wrong with this except the missing newline and the
unecessary header file.

Till
 
I

Ioannis Vranos

Bruce said:
I don't know why it didn't compile with gcc
in cygwin. If I change cout to std::cout,
I got more errors .... could this be namespace
issue, or maybe setting in cygwin ? or maybe
some careless mistake ?

Pls help, thanks !


#include <iostream>


Not needed:
#include <iomanip>



int main()
{

std::

cout << "test" ;

return 0;
}



The command line as i use it:

g++ -std=c++98 -pedantic-errors -O3 -Wall whatever.cpp -o whatever






Ioannis Vranos
 
M

Meihui Fan

please try to compile it with g++.

Bruce дµÀ:
I don't know why it didn't compile with gcc
in cygwin. If I change cout to std::cout,
I got more errors .... could this be namespace
issue, or maybe setting in cygwin ? or maybe
some careless mistake ?

Pls help, thanks !


#include <iostream>
#include <iomanip>

int main()
{

cout << "test" ; std::cout << "test";

return 0;
}

--

Very truly yours,

_______________________
Meihui Fan (·¶ÃÀ»Ô)

Laboratory of Structural Biology
School of Life Science
Univ. of Sci. & Tech. of China (USTC)

E-mail: (e-mail address removed)
Phone: +86(0)-551-3663380 (D)
+86(0)-551-3603754 (L)
Addr: Room 438, Bulding 4, P.O.Box 4
Hefei City, Anhui Province
230027, P.R. China
 
B

Bruce

It compiles now... thanks everyone.
bruce


Meihui Fan said:
please try to compile it with g++.

Bruce ????:

--

Very truly yours,

_______________________
Meihui Fan (??????)

Laboratory of Structural Biology
School of Life Science
Univ. of Sci. & Tech. of China (USTC)

E-mail: (e-mail address removed)
Phone: +86(0)-551-3663380 (D)
+86(0)-551-3603754 (L)
Addr: Room 438, Bulding 4, P.O.Box 4
Hefei City, Anhui Province
230027, P.R. China
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,440
Latest member
YoungBorel

Latest Threads

Top