The g++ -fconserve-space flag

Ferad Zyulkyarov feradz@gmail.com
Tue Mar 20 19:37:00 GMT 2007


Hi,

I want to port an application written in C into C++. When compiling
the code with the C compiler (gcc) some of the variables are compiled
as common symbols that the linker treats without problems. But when I
compile the code with g++ these common symbols are put in BSS section
and at link time, the linker reports for multiple definitions of the
same variable in different object files.

Before writing here, I looked for some solution and as I understand
the -fconserve-space flag is supposed to solve my problem. There is
another posting in the mail grup that relates to -fconserve-space flag
that it doesn't have any effect
(http://gcc.gnu.org/ml/gcc-help/2004-08/threads.html#00008). The
suggested solutions are to define the variables that cause the problem
as either static or extern. Static definition changes the
logic/semantics of the application, whereas the extern declaration
will involve a lot of code refactoring :(

I would welcome all the comments that would save me the huge burden of
code rewriting.

Thanks,
Ferad

-- 
Ferad Zyulkyarov
Barcelona Supercomputing Center



More information about the Gcc-help mailing list