This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: compiles under g++ but not gcc


sol <sol@avalon.pascal-central.com> writes:

> Hello, not sure I'm posting this to the right list, but I couldn't seem
> to find any others.

This question is appropriate for gcc-help@gcc.gnu.org, or for a
general learning-to-program group, but not for gcc@gcc.gnu.org.
gcc@gcc.gnu.org is for discussion of development _of_, not _with_,
gcc.

I will answer this question anyway, but please do not post further
such questions.

> I've noticed a problem compiling under g++ and gcc. a program I am
> working on compiles fine under g++, but gives a number of errors
> with gcc.  I have defined a simple structure in a header file,
> included this header in the main file that uses this structure, and
> when I compile under gcc, I get errors related to all variables of
> that structure type (the one defined in the header); it does not
> recognize the structure type that was defined in the header. When
> compiling under g++, there is no problem at all.

Since you did not show us any code, I can only guess what your problem
is.  You have probably run afoul of a well-known difference between C
and C++.  In C++, if you write

    struct S { int whatever; };

you may then write 

    S variable;

In C by contrast you must write

    struct S variable;

unless you use a typedef to define 'S' as equivalent to 'struct S'.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]