public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Compiling and Linking help
@ 2005-11-08  8:31 Djekic Dusan
  2005-11-08  8:43 ` Aseem Rastogi
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Djekic Dusan @ 2005-11-08  8:31 UTC (permalink / raw)
  To: gcc-help

Hello!
I have the the problem related to compiling and linking the following:

a.h
int a( ) { };

b.h
#include a.h
class B { B( ); };

b.cpp
#include "b.h"
B::B( ) { a( ); }

c.h
class C { C( ); };

c.cpp
#include "c.h"
C::C( ) { }

main.cpp
#include "b.h"
#include "c.h"
B b;
C c;


compiling:  g++ -c b.cpp
                 g++ -c c.cpp
                 g++ -c main.cpp

linking:       g++ -o out b.o c.o main.o


Here I get no compilation errors, but do get linking errors stating
multiple definitions of everything regarding a.h. I found out this is
the product of double compiling everything regarding   a.h in b.o and
main.o, but could not find the way how to write proper and simple
Makefile, but to have object files for b, c and main, and afterwards
linked together. Could you help me with this?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-08  8:31 Compiling and Linking help Djekic Dusan
@ 2005-11-08  8:43 ` Aseem Rastogi
  2005-11-08  8:45 ` Dima Sorkin
  2005-11-08 15:11 ` John Love-Jensen
  2 siblings, 0 replies; 14+ messages in thread
From: Aseem Rastogi @ 2005-11-08  8:43 UTC (permalink / raw)
  To: Djekic Dusan; +Cc: gcc-help

to keep code clean and simple, generally function implementations are 
not written in .h files. they should only contain declarations and then 
.cpp files should have implementations which can then be linked.

btw, making a () function inline could help. but it should be avoided 
keeping in mind above.

regards,
aseem.

Djekic Dusan wrote:

>Hello!
>I have the the problem related to compiling and linking the following:
>
>a.h
>int a( ) { };
>
>b.h
>#include a.h
>class B { B( ); };
>
>b.cpp
>#include "b.h"
>B::B( ) { a( ); }
>
>c.h
>class C { C( ); };
>
>c.cpp
>#include "c.h"
>C::C( ) { }
>
>main.cpp
>#include "b.h"
>#include "c.h"
>B b;
>C c;
>
>
>compiling:  g++ -c b.cpp
>                 g++ -c c.cpp
>                 g++ -c main.cpp
>
>linking:       g++ -o out b.o c.o main.o
>
>
>Here I get no compilation errors, but do get linking errors stating
>multiple definitions of everything regarding a.h. I found out this is
>the product of double compiling everything regarding   a.h in b.o and
>main.o, but could not find the way how to write proper and simple
>Makefile, but to have object files for b, c and main, and afterwards
>linked together. Could you help me with this?
>


-- 
The end is always good. If it's not good, it's not the end.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-08  8:31 Compiling and Linking help Djekic Dusan
  2005-11-08  8:43 ` Aseem Rastogi
@ 2005-11-08  8:45 ` Dima Sorkin
  2005-11-08  9:54   ` Djekic Dusan
  2005-11-08 15:11 ` John Love-Jensen
  2 siblings, 1 reply; 14+ messages in thread
From: Dima Sorkin @ 2005-11-08  8:45 UTC (permalink / raw)
  To: Djekic Dusan; +Cc: gcc-help

On 11/8/05, Djekic Dusan  wrote:
>
> a.h
> int a( ) { };
>

Hi.
 I have encountered this problem too.
Explicitly writing "inline int a() {}" instead
of your piece of code helped.

Or , if "a" will be a big function (not intended for inlining),
you will have to
move it's definition into a.cpp, and in a.h there will be
only declaration.

Regards,
 Dima.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-08  8:45 ` Dima Sorkin
@ 2005-11-08  9:54   ` Djekic Dusan
  2005-11-08  9:59     ` Aseem Rastogi
  0 siblings, 1 reply; 14+ messages in thread
From: Djekic Dusan @ 2005-11-08  9:54 UTC (permalink / raw)
  To: Dima Sorkin; +Cc: gcc-help

a.h is not the file I could change. I am just using it from third
party. Files in my project are b.h, c.h, and so forth. I forgot that
all my .h files are enclosed within suitable #ifndef, #define, and
#endif. And the question is how to have .o files of all b, c, and so
forth files linked without having multiple definition linking error of
everything from a, since everything from a is defined twice:
1 - in b.o (since b.h includes a.h)
2 - in main.o (since main.cpp includes b.h which includes a.h)

On 11/8/05, Dima Sorkin <dima.sorkin@gmail.com> wrote:
> On 11/8/05, Djekic Dusan  wrote:
> >
> > a.h
> > int a( ) { };
> >
>
> Hi.
>  I have encountered this problem too.
> Explicitly writing "inline int a() {}" instead
> of your piece of code helped.
>
> Or , if "a" will be a big function (not intended for inlining),
> you will have to
> move it's definition into a.cpp, and in a.h there will be
> only declaration.
>
> Regards,
>  Dima.
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-08  9:54   ` Djekic Dusan
@ 2005-11-08  9:59     ` Aseem Rastogi
  2005-11-08 10:03       ` Djekic Dusan
  2005-11-08 10:10       ` Djekic Dusan
  0 siblings, 2 replies; 14+ messages in thread
From: Aseem Rastogi @ 2005-11-08  9:59 UTC (permalink / raw)
  To: Djekic Dusan; +Cc: Dima Sorkin, gcc-help

do not include a.h in b.h and declate a () as an extern function in b.h

include a.h in main.cpp.

it should work.

Djekic Dusan wrote:

>a.h is not the file I could change. I am just using it from third
>party. Files in my project are b.h, c.h, and so forth. I forgot that
>all my .h files are enclosed within suitable #ifndef, #define, and
>#endif. And the question is how to have .o files of all b, c, and so
>forth files linked without having multiple definition linking error of
>everything from a, since everything from a is defined twice:
>1 - in b.o (since b.h includes a.h)
>2 - in main.o (since main.cpp includes b.h which includes a.h)
>
>On 11/8/05, Dima Sorkin <dima.sorkin@gmail.com> wrote:
>
>>On 11/8/05, Djekic Dusan  wrote:
>>
>>>a.h
>>>int a( ) { };
>>>
>>Hi.
>> I have encountered this problem too.
>>Explicitly writing "inline int a() {}" instead
>>of your piece of code helped.
>>
>>Or , if "a" will be a big function (not intended for inlining),
>>you will have to
>>move it's definition into a.cpp, and in a.h there will be
>>only declaration.
>>
>>Regards,
>> Dima.
>>
>>
>


-- 
The end is always good. If it's not good, it's not the end.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-08  9:59     ` Aseem Rastogi
@ 2005-11-08 10:03       ` Djekic Dusan
  2005-11-08 10:10       ` Djekic Dusan
  1 sibling, 0 replies; 14+ messages in thread
From: Djekic Dusan @ 2005-11-08 10:03 UTC (permalink / raw)
  To: Aseem Rastogi; +Cc: gcc-help

include a.h in main.cpp does not solve the problem. I've got the same
error, which is not for surprise, since a.h again is twice defined: in
b.o and in main.o

On 11/8/05, Aseem Rastogi <aseem@india.tejasnetworks.com> wrote:
> do not include a.h in b.h and declate a () as an extern function in b.h
>
> include a.h in main.cpp.
>
> it should work.
>
> Djekic Dusan wrote:
>
> >a.h is not the file I could change. I am just using it from third
> >party. Files in my project are b.h, c.h, and so forth. I forgot that
> >all my .h files are enclosed within suitable #ifndef, #define, and
> >#endif. And the question is how to have .o files of all b, c, and so
> >forth files linked without having multiple definition linking error of
> >everything from a, since everything from a is defined twice:
> >1 - in b.o (since b.h includes a.h)
> >2 - in main.o (since main.cpp includes b.h which includes a.h)
> >
> >On 11/8/05, Dima Sorkin <dima.sorkin@gmail.com> wrote:
> >
> >>On 11/8/05, Djekic Dusan  wrote:
> >>
> >>>a.h
> >>>int a( ) { };
> >>>
> >>Hi.
> >> I have encountered this problem too.
> >>Explicitly writing "inline int a() {}" instead
> >>of your piece of code helped.
> >>
> >>Or , if "a" will be a big function (not intended for inlining),
> >>you will have to
> >>move it's definition into a.cpp, and in a.h there will be
> >>only declaration.
> >>
> >>Regards,
> >> Dima.
> >>
> >>
> >
>
>
> --
> The end is always good. If it's not good, it's not the end.
>
>
>
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-08  9:59     ` Aseem Rastogi
  2005-11-08 10:03       ` Djekic Dusan
@ 2005-11-08 10:10       ` Djekic Dusan
  2005-11-08 10:17         ` Aseem Rastogi
  1 sibling, 1 reply; 14+ messages in thread
From: Djekic Dusan @ 2005-11-08 10:10 UTC (permalink / raw)
  To: Aseem Rastogi; +Cc: gcc-help

the previous message was a mistake, since I have not correctly the first line.
Yes, you are right about it. But, in reality, a.h includes many
functions, and including all of them is rather tedious job. Is there
any other solution?

On 11/8/05, Aseem Rastogi <aseem@india.tejasnetworks.com> wrote:
> do not include a.h in b.h and declate a () as an extern function in b.h
>
> include a.h in main.cpp.
>
> it should work.
>
> Djekic Dusan wrote:
>
> >a.h is not the file I could change. I am just using it from third
> >party. Files in my project are b.h, c.h, and so forth. I forgot that
> >all my .h files are enclosed within suitable #ifndef, #define, and
> >#endif. And the question is how to have .o files of all b, c, and so
> >forth files linked without having multiple definition linking error of
> >everything from a, since everything from a is defined twice:
> >1 - in b.o (since b.h includes a.h)
> >2 - in main.o (since main.cpp includes b.h which includes a.h)
> >
> >On 11/8/05, Dima Sorkin <dima.sorkin@gmail.com> wrote:
> >
> >>On 11/8/05, Djekic Dusan  wrote:
> >>
> >>>a.h
> >>>int a( ) { };
> >>>
> >>Hi.
> >> I have encountered this problem too.
> >>Explicitly writing "inline int a() {}" instead
> >>of your piece of code helped.
> >>
> >>Or , if "a" will be a big function (not intended for inlining),
> >>you will have to
> >>move it's definition into a.cpp, and in a.h there will be
> >>only declaration.
> >>
> >>Regards,
> >> Dima.
> >>
> >>
> >
>
>
> --
> The end is always good. If it's not good, it's not the end.
>
>
>
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-08 10:10       ` Djekic Dusan
@ 2005-11-08 10:17         ` Aseem Rastogi
  2005-11-08 10:20           ` Djekic Dusan
  0 siblings, 1 reply; 14+ messages in thread
From: Aseem Rastogi @ 2005-11-08 10:17 UTC (permalink / raw)
  To: Djekic Dusan; +Cc: gcc-help

may be this will works.

include a.h in b.cpp and not in b.h if possible.

Djekic Dusan wrote:

>the previous message was a mistake, since I have not correctly the first line.
>Yes, you are right about it. But, in reality, a.h includes many
>functions, and including all of them is rather tedious job. Is there
>any other solution?
>
>On 11/8/05, Aseem Rastogi <aseem@india.tejasnetworks.com> wrote:
>
>>do not include a.h in b.h and declate a () as an extern function in b.h
>>
>>include a.h in main.cpp.
>>
>>it should work.
>>
>>Djekic Dusan wrote:
>>
>>>a.h is not the file I could change. I am just using it from third
>>>party. Files in my project are b.h, c.h, and so forth. I forgot that
>>>all my .h files are enclosed within suitable #ifndef, #define, and
>>>#endif. And the question is how to have .o files of all b, c, and so
>>>forth files linked without having multiple definition linking error of
>>>everything from a, since everything from a is defined twice:
>>>1 - in b.o (since b.h includes a.h)
>>>2 - in main.o (since main.cpp includes b.h which includes a.h)
>>>
>>>On 11/8/05, Dima Sorkin <dima.sorkin@gmail.com> wrote:
>>>
>>>>On 11/8/05, Djekic Dusan  wrote:
>>>>
>>>>>a.h
>>>>>int a( ) { };
>>>>>
>>>>Hi.
>>>>I have encountered this problem too.
>>>>Explicitly writing "inline int a() {}" instead
>>>>of your piece of code helped.
>>>>
>>>>Or , if "a" will be a big function (not intended for inlining),
>>>>you will have to
>>>>move it's definition into a.cpp, and in a.h there will be
>>>>only declaration.
>>>>
>>>>Regards,
>>>>Dima.
>>>>
>>>>
>>
>>--
>>The end is always good. If it's not good, it's not the end.
>>
>>
>>
>>
>


-- 
The end is always good. If it's not good, it's not the end.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-08 10:17         ` Aseem Rastogi
@ 2005-11-08 10:20           ` Djekic Dusan
  2005-11-08 10:31             ` Aseem Rastogi
  0 siblings, 1 reply; 14+ messages in thread
From: Djekic Dusan @ 2005-11-08 10:20 UTC (permalink / raw)
  To: Aseem Rastogi; +Cc: gcc-help

unfortunately a.h also have some classes declarations and
implementations within it, and in b.h I declare pointers to some of
those classes.

On 11/8/05, Aseem Rastogi <aseem@india.tejasnetworks.com> wrote:
> may be this will works.
>
> include a.h in b.cpp and not in b.h if possible.
>
> Djekic Dusan wrote:
>
> >the previous message was a mistake, since I have not correctly the first line.
> >Yes, you are right about it. But, in reality, a.h includes many
> >functions, and including all of them is rather tedious job. Is there
> >any other solution?
> >
> >On 11/8/05, Aseem Rastogi <aseem@india.tejasnetworks.com> wrote:
> >
> >>do not include a.h in b.h and declate a () as an extern function in b.h
> >>
> >>include a.h in main.cpp.
> >>
> >>it should work.
> >>
> >>Djekic Dusan wrote:
> >>
> >>>a.h is not the file I could change. I am just using it from third
> >>>party. Files in my project are b.h, c.h, and so forth. I forgot that
> >>>all my .h files are enclosed within suitable #ifndef, #define, and
> >>>#endif. And the question is how to have .o files of all b, c, and so
> >>>forth files linked without having multiple definition linking error of
> >>>everything from a, since everything from a is defined twice:
> >>>1 - in b.o (since b.h includes a.h)
> >>>2 - in main.o (since main.cpp includes b.h which includes a.h)
> >>>
> >>>On 11/8/05, Dima Sorkin <dima.sorkin@gmail.com> wrote:
> >>>
> >>>>On 11/8/05, Djekic Dusan  wrote:
> >>>>
> >>>>>a.h
> >>>>>int a( ) { };
> >>>>>
> >>>>Hi.
> >>>>I have encountered this problem too.
> >>>>Explicitly writing "inline int a() {}" instead
> >>>>of your piece of code helped.
> >>>>
> >>>>Or , if "a" will be a big function (not intended for inlining),
> >>>>you will have to
> >>>>move it's definition into a.cpp, and in a.h there will be
> >>>>only declaration.
> >>>>
> >>>>Regards,
> >>>>Dima.
> >>>>
> >>>>
> >>
> >>--
> >>The end is always good. If it's not good, it's not the end.
> >>
> >>
> >>
> >>
> >
>
>
> --
> The end is always good. If it's not good, it's not the end.
>
>
>
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-08 10:20           ` Djekic Dusan
@ 2005-11-08 10:31             ` Aseem Rastogi
  2005-11-08 10:40               ` Djekic Dusan
  0 siblings, 1 reply; 14+ messages in thread
From: Aseem Rastogi @ 2005-11-08 10:31 UTC (permalink / raw)
  To: Djekic Dusan; +Cc: gcc-help

i would suggest rewrite a.h for better future.

its not important what you get from ur predecessors but what you leave 
behind for ur successors. :)

Djekic Dusan wrote:

>unfortunately a.h also have some classes declarations and
>implementations within it, and in b.h I declare pointers to some of
>those classes.
>
>On 11/8/05, Aseem Rastogi <aseem@india.tejasnetworks.com> wrote:
>
>>may be this will works.
>>
>>include a.h in b.cpp and not in b.h if possible.
>>
>>Djekic Dusan wrote:
>>
>>>the previous message was a mistake, since I have not correctly the first line.
>>>Yes, you are right about it. But, in reality, a.h includes many
>>>functions, and including all of them is rather tedious job. Is there
>>>any other solution?
>>>
>>>On 11/8/05, Aseem Rastogi <aseem@india.tejasnetworks.com> wrote:
>>>
>>>>do not include a.h in b.h and declate a () as an extern function in b.h
>>>>
>>>>include a.h in main.cpp.
>>>>
>>>>it should work.
>>>>
>>>>Djekic Dusan wrote:
>>>>
>>>>>a.h is not the file I could change. I am just using it from third
>>>>>party. Files in my project are b.h, c.h, and so forth. I forgot that
>>>>>all my .h files are enclosed within suitable #ifndef, #define, and
>>>>>#endif. And the question is how to have .o files of all b, c, and so
>>>>>forth files linked without having multiple definition linking error of
>>>>>everything from a, since everything from a is defined twice:
>>>>>1 - in b.o (since b.h includes a.h)
>>>>>2 - in main.o (since main.cpp includes b.h which includes a.h)
>>>>>
>>>>>On 11/8/05, Dima Sorkin <dima.sorkin@gmail.com> wrote:
>>>>>
>>>>>>On 11/8/05, Djekic Dusan  wrote:
>>>>>>
>>>>>>>a.h
>>>>>>>int a( ) { };
>>>>>>>
>>>>>>Hi.
>>>>>>I have encountered this problem too.
>>>>>>Explicitly writing "inline int a() {}" instead
>>>>>>of your piece of code helped.
>>>>>>
>>>>>>Or , if "a" will be a big function (not intended for inlining),
>>>>>>you will have to
>>>>>>move it's definition into a.cpp, and in a.h there will be
>>>>>>only declaration.
>>>>>>
>>>>>>Regards,
>>>>>>Dima.
>>>>>>
>>>>>>
>>>>--
>>>>The end is always good. If it's not good, it's not the end.
>>>>
>>>>
>>>>
>>>>
>>
>>--
>>The end is always good. If it's not good, it's not the end.
>>
>>
>>
>>
>


-- 
The end is always good. If it's not good, it's not the end.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-08 10:31             ` Aseem Rastogi
@ 2005-11-08 10:40               ` Djekic Dusan
  0 siblings, 0 replies; 14+ messages in thread
From: Djekic Dusan @ 2005-11-08 10:40 UTC (permalink / raw)
  To: Aseem Rastogi; +Cc: gcc-help

a.h is still being used by other developers, so unfortunately I am not
entitled to change it.
Could you suggest who might be able to give the right answer?

On 11/8/05, Aseem Rastogi <aseem@india.tejasnetworks.com> wrote:
> i would suggest rewrite a.h for better future.
>
> its not important what you get from ur predecessors but what you leave
> behind for ur successors. :)
>
> Djekic Dusan wrote:
>
> >unfortunately a.h also have some classes declarations and
> >implementations within it, and in b.h I declare pointers to some of
> >those classes.
> >
> >On 11/8/05, Aseem Rastogi <aseem@india.tejasnetworks.com> wrote:
> >
> >>may be this will works.
> >>
> >>include a.h in b.cpp and not in b.h if possible.
> >>
> >>Djekic Dusan wrote:
> >>
> >>>the previous message was a mistake, since I have not correctly the first line.
> >>>Yes, you are right about it. But, in reality, a.h includes many
> >>>functions, and including all of them is rather tedious job. Is there
> >>>any other solution?
> >>>
> >>>On 11/8/05, Aseem Rastogi <aseem@india.tejasnetworks.com> wrote:
> >>>
> >>>>do not include a.h in b.h and declate a () as an extern function in b.h
> >>>>
> >>>>include a.h in main.cpp.
> >>>>
> >>>>it should work.
> >>>>
> >>>>Djekic Dusan wrote:
> >>>>
> >>>>>a.h is not the file I could change. I am just using it from third
> >>>>>party. Files in my project are b.h, c.h, and so forth. I forgot that
> >>>>>all my .h files are enclosed within suitable #ifndef, #define, and
> >>>>>#endif. And the question is how to have .o files of all b, c, and so
> >>>>>forth files linked without having multiple definition linking error of
> >>>>>everything from a, since everything from a is defined twice:
> >>>>>1 - in b.o (since b.h includes a.h)
> >>>>>2 - in main.o (since main.cpp includes b.h which includes a.h)
> >>>>>
> >>>>>On 11/8/05, Dima Sorkin <dima.sorkin@gmail.com> wrote:
> >>>>>
> >>>>>>On 11/8/05, Djekic Dusan  wrote:
> >>>>>>
> >>>>>>>a.h
> >>>>>>>int a( ) { };
> >>>>>>>
> >>>>>>Hi.
> >>>>>>I have encountered this problem too.
> >>>>>>Explicitly writing "inline int a() {}" instead
> >>>>>>of your piece of code helped.
> >>>>>>
> >>>>>>Or , if "a" will be a big function (not intended for inlining),
> >>>>>>you will have to
> >>>>>>move it's definition into a.cpp, and in a.h there will be
> >>>>>>only declaration.
> >>>>>>
> >>>>>>Regards,
> >>>>>>Dima.
> >>>>>>
> >>>>>>
> >>>>--
> >>>>The end is always good. If it's not good, it's not the end.
> >>>>
> >>>>
> >>>>
> >>>>
> >>
> >>--
> >>The end is always good. If it's not good, it's not the end.
> >>
> >>
> >>
> >>
> >
>
>
> --
> The end is always good. If it's not good, it's not the end.
>
>
>
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-08  8:31 Compiling and Linking help Djekic Dusan
  2005-11-08  8:43 ` Aseem Rastogi
  2005-11-08  8:45 ` Dima Sorkin
@ 2005-11-08 15:11 ` John Love-Jensen
  2005-11-09 11:28   ` Dima Sorkin
  2 siblings, 1 reply; 14+ messages in thread
From: John Love-Jensen @ 2005-11-08 15:11 UTC (permalink / raw)
  To: Djekic Dusan, MSX to GCC

Hi Djekic,

a.h is malformed.  It violates ODR.

>a.h is not the file I could change.

You either have to change it, or you have to rewrite it.

As it stands, a.h is malformed.

Look on s9.2.1 of Stroustrup's C++ Programming Language (3rd or Special
edition).  Those are the kinds of things that go in header files.  a.h
contains things that should not be present in a header file.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-08 15:11 ` John Love-Jensen
@ 2005-11-09 11:28   ` Dima Sorkin
  2005-11-09 16:07     ` corey taylor
  0 siblings, 1 reply; 14+ messages in thread
From: Dima Sorkin @ 2005-11-09 11:28 UTC (permalink / raw)
  To: gcc-help

On 11/8/05, John Love-Jensen  wrote:
> a.h is malformed.  It violates ODR.
> Look on s9.2.1 of Stroustrup's C++ Programming Language (3rd or Special
> edition).  Those are the kinds of things that go in header files.  a.h
> contains things that should not be present in a header file.

Hi.
 It took me time to understand that ODR stays for One Definition Rule...

 I always thought that if compiler meets function definition, and he didn't
meet it's declaration before, than it is implicit suggestion to inline
the function
(like with the inline member functions of a class).

Regards,
 Dima.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Compiling and Linking help
  2005-11-09 11:28   ` Dima Sorkin
@ 2005-11-09 16:07     ` corey taylor
  0 siblings, 0 replies; 14+ messages in thread
From: corey taylor @ 2005-11-09 16:07 UTC (permalink / raw)
  To: Dima Sorkin; +Cc: gcc-help

> Hi.
>  It took me time to understand that ODR stays for One Definition Rule...

Yes, even #ifndef/#define/#endif wrappers wouldn't help here.

>  I always thought that if compiler meets function definition, and he didn't
> meet it's declaration before, than it is implicit suggestion to inline
> the function
> (like with the inline member functions of a class).

No, only functions with a body that are defined inside of the class
declaration are implicitly inline, everything else must be marked
inline at definition.

What *might* work, and I've not tested this with gcc, is the use of a
pre-compiled heeader that includes your a.h file so that it isn't
constantly parsed and defined.

corey

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2005-11-09 16:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-08  8:31 Compiling and Linking help Djekic Dusan
2005-11-08  8:43 ` Aseem Rastogi
2005-11-08  8:45 ` Dima Sorkin
2005-11-08  9:54   ` Djekic Dusan
2005-11-08  9:59     ` Aseem Rastogi
2005-11-08 10:03       ` Djekic Dusan
2005-11-08 10:10       ` Djekic Dusan
2005-11-08 10:17         ` Aseem Rastogi
2005-11-08 10:20           ` Djekic Dusan
2005-11-08 10:31             ` Aseem Rastogi
2005-11-08 10:40               ` Djekic Dusan
2005-11-08 15:11 ` John Love-Jensen
2005-11-09 11:28   ` Dima Sorkin
2005-11-09 16:07     ` corey taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).