[SDL] error with 'multiple definition'
Will Langford
unfies at gmail.com
Tue Feb 13 13:56:37 PST 2007
No, he's trapped multiple declarations within each object. So each object is
guarunteed to have A.h ooeygooey goodness only once. If he's compiling with
multiple .c files that include A.h, then each one will have a 'rem'.
When you link the multiple objects together, the linker will see each 'rem'
and get confused.
-Will
On 2/13/07, Lilith Calbridge <lilith at dcccd.edu> wrote:
>
> But he's trapped subsequent declarations. On the first pass it checks to
> see if A_H is defined. If not, it defines it. The remainder is enclosed
> within the conditional. On a second pass it should find that A_H is defined
> and thus will skip everything up to the #endif.
>
> The only other thing I can think of, except for the compiler not working
> properly, is that rem is declared somewhere else in the program.
>
> Lilith
>
> >>> On 2/13/2007 at 3:38 PM, "Will Langford" <unfies at gmail.com> wrote:
> > If more than one file #include's A.H, each one will attempt to declare
> > std::string rem. Fine during compiling, but when it comes time to link,
> the
> > linker will see multiple things with the same name.
> >
> >
> > On 2/13/07, nathayan de los valles <semiogro at hotmail.com> wrote:
> >>
> >> Hi all,
> >> Perhaps this is not the best place to throw my doubt... but I have no
> >> friends who can answer me.
> >> I am using C++ and SDL.
> >> I have several files .h like this:
> >> A.h
> >> #ifndef A_H
> >> #define A_H
> >> #include <iostream>
> >> #include <sstream>
> >> #include <string>
> >> #include <fstream>
> >> std::string rem = "//";
> >> //more definitions
> >> #endif
> >>
> >> B.h
> >> #ifndef B_H
> >> #define B_H
> >> #include "A.h"
> >> //definitions
> >> #endif
> >>
> >> My compiler says me: multiple definition of 'rem'. I think my
> compiler
> >> doesn't run properly. Any idea?
> >>
> >> I use:
> >> Dev C++ 4.9.9.2 (I know there is more interesting information but I
> don't
> >> remember where to find it).
> >> Thanks in advance.
> >>
> >> _________________________________________________________________
> >> Horóscopo, tarot, numerología... Escucha lo que te dicen los astros.
> >> http://astrocentro.msn.es/
> >>
> >> _______________________________________________
> >> SDL mailing list
> >> SDL at lists.libsdl.org
> >> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> >>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070213/82df778f/attachment.htm
More information about the SDL
mailing list