This is the mail archive of the gcc-help@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: The g++ -fconserve-space flag


Thanks John,

Your answer helped me to understand what the actual problem is.

On 3/20/07, John Love-Jensen <eljay@adobe.com> wrote:
Hi Ferad,

Sounds like you have header files that are defining symbols, when what you
want is for the header files to declare them (not define them).

Take a look at Stroustrup's C++ Programming Language (special edition, or
third edition) section B.2.2 "C Code That Is Not C++".

This is valid C, but not valid C++:
int foo;
int foo;

In C, only one foo is defined.

In C++, the second foo causes an error in the translation unit.  (And if the
int foo is in different translation units, it causes an error at link time.
Violation of ODR.)

In C++, you may need to do this in your header files:

extern int foo; // Declaration, not a definition.

HTH,
--Eljay




--
Ferad Zyulkyarov
Barcelona Supercomputing Center


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