compile error

I am a newbee to c++. My first cpp is failing while compilation. I am executing it on Solaris.
My program:

#include <iostream>
using namespace std;
int main()
{
cout << "Hello\n";
}
~


Compilation and error:

g++ test.cpp -o test
In file included from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/include/sys/signal.h:132,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/include/pthread.h:22,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/sparc-sun-solaris2.6/bits/gthr-default.h:43,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/sparc-sun-solaris2.6/bits/gthr.h:96,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/sparc-sun-solaris2.6/bits/c++io.h:37,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/iosfwd:47,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/ios:44,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/ostream:45,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/iostream:45,
from test.cpp:1:
/usr/include/sys/siginfo.h:259: error: `ctid_t' does not name a type
/usr/include/sys/siginfo.h:260: error: `zoneid_t' does not name a type
/usr/include/sys/siginfo.h:390: error: `ctid_t' does not name a type
/usr/include/sys/siginfo.h:391: error: `zoneid_t' does not name a type
In file included from /usr/include/wchar.h:13,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/cwchar:54,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/bits/postypes.h:46,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/iosfwd:50,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/ios:44,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/ostream:45,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/iostream:45,
from test.cpp:1:
/usr/include/iso/wchar_iso.h:120: error: conflicting declaration 'typedef struct __FILE FILE'
/opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/include/stdio.h:200: error: 'FILE' has a previous declaration as `typedef struct FILE FILE'
/usr/include/iso/wchar_iso.h:120: error: declaration of `typedef struct __FILE FILE'
/opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/include/stdio.h:200: error: conflicts with previous declaration `typedef struct FILE FILE'
/usr/include/iso/wchar_iso.h:120: error: declaration of `typedef struct __FILE FILE'
/opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/include/stdio.h:200: error: conflicts with previous declaration `typedef struct FILE FILE'
/usr/include/iso/wchar_iso.h:120: error: declaration of `typedef struct __FILE FILE'
/opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/include/stdio.h:200: error: conflicts with previous declaration `typedef struct FILE FILE'
In file included from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/bits/postypes.h:46,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/iosfwd:50,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/ios:44,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/ostream:45,
from /opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/iostream:45,
from test.cpp:1:
/opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/cwchar:65: error: conflicting declaration 'typedef struct mbstate_t mbstate_t'
/usr/include/iso/wchar_iso.h:115: error: 'mbstate_t' has a previous declaration as `typedef struct __mbstate_t mbstate_t'
/opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/cwchar:65: error: declaration of `typedef struct mbstate_t mbstate_t'
/usr/include/iso/wchar_iso.h:115: error: conflicts with previous declaration `typedef struct __mbstate_t mbstate_t'
/opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/cwchar:65: error: declaration of `typedef struct mbstate_t mbstate_t'
/usr/include/iso/wchar_iso.h:115: error: conflicts with previous declaration `typedef struct __mbstate_t mbstate_t'
/opt/local/bin/../lib/gcc/sparc-sun-solaris2.6/3.4.6/../../../../include/c++/3.4.6/cwchar:65: error: declaration of `typedef struct mbstate_t mbstate_t'
/usr/include/iso/wchar_iso.h:115: error: conflicts with previous declaration `typedef struct __mbstate_t mbstate_t'
======================================

Please let me know
1. what would went wrong
2. how to overcome
3. how to debug
You have two conlicting sets of header files, gcc headers and the system headers.
so, which header you want me to remove? How to overcome the issue?
when using iostream library you use the endl keyword to skip lines

eg

cout<<"hi"<<endl;


\n is part of the stdio.h library

to use it you have to:

#include <stdio.h>
The code is ok, as far as it goes. You need to sort out your build environment, specifically your include and library paths.
Topic archived. No new replies allowed.