By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,388 Members | 1,988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,388 IT Pros & Developers. It's quick & easy.

Problems trying to compile very simple code

P: n/a
Hi All,

I have three very simple files as below.
When I try and compile these with g++ -ansi -Wall -pedantic -o crap Base.h
Other.h
I get an error:

Base.h:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.htmlfor instructions.
Other.h:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.htmlfor instructions.
make: *** [all] Error 1

Can anyone tell me why? If I remove the #include <iostreamit compiles
without error.

Thanks for your help

Michael

-----------first file--Base.h--------

#ifndef _Base_
#define _Base_

#include <iostream>
class Base {

};

#endif

-------------second file--Other.h-------

#endif

#ifndef _Other_
#define _Other_

#include "Base.h"

class Other {
};

#endif

-------------Third file---crap.cpp-------

int main(){
}

Mar 19 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Michael wrote:
Hi All,

I have three very simple files as below.
When I try and compile these with g++ -ansi -Wall -pedantic -o crap Base.h
Other.h
I get an error:

Base.h:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.htmlfor instructions.
Other.h:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.htmlfor instructions.
make: *** [all] Error 1

Can anyone tell me why? If I remove the #include <iostreamit compiles
without error.

Thanks for your help

Michael

-----------first file--Base.h--------

#ifndef _Base_
#define _Base_

#include <iostream>
class Base {

};

#endif

-------------second file--Other.h-------

#endif

#ifndef _Other_
#define _Other_

#include "Base.h"

class Other {
};

#endif

-------------Third file---crap.cpp-------

int main(){
}

Probably not the cause of your problem, but your program is ill-formed.
Any identifier with a leading underscore followed by an uppercase
letter (e.g. _Base_ or _Other_) is reserved for use by the
implementation -- you may not use it for your own purposes.

As for the rest, a g++ internal error should be posted in gnu.g++.help,
we don't discuss compiler specifics here.
Mar 19 '07 #2

P: n/a

"Michael" <mi*********@yahoo.comwrote in message
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
Hi All,

I have three very simple files as below.
When I try and compile these with g++ -ansi -Wall -pedantic -o crap Base.h
Other.h
Why are you trying to compile a header? You compile code (.cpp) files, not
code files.

I don't use g++ but with your sample line I think you should be doing:
g++ -ansi -Wall -pedantic -o crap crap.cpp

crap.cpp itself will pull in the headers IF you use include statments. That
is, change crap.cpp to be:

#include "Base.h"
#include "Other.h"

int main()
{
}
I get an error:

Base.h:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.htmlfor instructions.
Other.h:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.htmlfor instructions.
make: *** [all] Error 1

Can anyone tell me why? If I remove the #include <iostreamit compiles
without error.

Thanks for your help

Michael

-----------first file--Base.h--------

#ifndef _Base_
#define _Base_

#include <iostream>
class Base {

};

#endif

-------------second file--Other.h-------

#endif

#ifndef _Other_
#define _Other_

#include "Base.h"

class Other {
};

#endif

-------------Third file---crap.cpp-------

int main(){
}

Mar 19 '07 #3

P: n/a

"Jim Langston" <ta*******@rocketmail.comwrote in message
news:TG**************@newsfe04.lga...
>
"Michael" <mi*********@yahoo.comwrote in message
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
>Hi All,

I have three very simple files as below.
When I try and compile these with g++ -ansi -Wall -pedantic -o crap
Base.h Other.h

Why are you trying to compile a header? You compile code (.cpp) files,
not code files.
My bad. I meant to say, You compile code (.cpp) files, not header (.h)
files.
I don't use g++ but with your sample line I think you should be doing:
g++ -ansi -Wall -pedantic -o crap crap.cpp

crap.cpp itself will pull in the headers IF you use include statments.
That is, change crap.cpp to be:

#include "Base.h"
#include "Other.h"

int main()
{
}
>I get an error:

Base.h:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.htmlfor instructions.
Other.h:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.htmlfor instructions.
make: *** [all] Error 1

Can anyone tell me why? If I remove the #include <iostreamit compiles
without error.

Thanks for your help

Michael

-----------first file--Base.h--------

#ifndef _Base_
#define _Base_

#include <iostream>
class Base {

};

#endif

-------------second file--Other.h-------

#endif

#ifndef _Other_
#define _Other_

#include "Base.h"

class Other {
};

#endif

-------------Third file---crap.cpp-------

int main(){
}


Mar 19 '07 #4

P: n/a

"Michael" <mi*********@yahoo.comskrev i meddelandet
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
Hi All,

I have three very simple files as below.
When I try and compile these with g++ -ansi -Wall -pedantic -o crap Base.h
Other.h
I get an error:

Base.h:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.htmlfor instructions.
Other.h:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.htmlfor instructions.
make: *** [all] Error 1

Can anyone tell me why? If I remove the #include <iostreamit compiles
without error.

Thanks for your help

Michael

-----------first file--Base.h--------

#ifndef _Base_
#define _Base_

#include <iostream>
class Base {

};

#endif

-------------second file--Other.h-------

#endif
Do you really have an #endif here? If so, why?
Bo Persson
>
#ifndef _Other_
#define _Other_

#include "Base.h"

class Other {
};

#endif

-------------Third file---crap.cpp-------

int main(){
}

Mar 19 '07 #5

P: n/a

"Bo Persson" <bo*@gmb.dkwrote in message
news:56*************@mid.individual.net...
>
"Michael" <mi*********@yahoo.comskrev i meddelandet
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
>Hi All,

I have three very simple files as below.
When I try and compile these with g++ -ansi -Wall -pedantic -o crap
Base.h Other.h
I get an error:

Base.h:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.htmlfor instructions.
Other.h:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.htmlfor instructions.
make: *** [all] Error 1

Can anyone tell me why? If I remove the #include <iostreamit compiles
without error.

Thanks for your help

Michael

-----------first file--Base.h--------

#ifndef _Base_
#define _Base_

#include <iostream>
class Base {

};

#endif

-------------second file--Other.h-------

#endif

Do you really have an #endif here? If so, why?
No, sorry, cut and paste error :-)
>
Bo Persson
>>
#ifndef _Other_
#define _Other_

#include "Base.h"

class Other {
};

#endif

-------------Third file---crap.cpp-------

int main(){
}


Mar 19 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.