Re: [gem5-users] Question about compile after adding global funcs

2019-11-07 Thread Ciro Santilli


On 11/7/19 2:28 PM, yuan wrote:
> Hi, All,
> 
> I suffered one problem of multiple definition when compiling, what I did 
> is adding some new functions I need in a file name my_func.hh under 
> src/mem/, and in the file cache.cc where I need these functions I use 
> #include “mem/my_func.hh”, but when I re-compile the gem5, it always 
> shows the error of multiple definition of “the name of my func”. Does 
> anyone have some hints on this?
> 

Are you putting your function definitions in the headers? If so, you 
have to put declarations in the headers and definitions in a my_func.cc 
file.

> Best,
> 
> Yuan
> 
> Sent from Mail  for 
> Windows 10
> 
> 
> ___
> gem5-users mailing list
> gem5-users@gem5.org
> http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
> 
___
gem5-users mailing list
gem5-users@gem5.org
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Re: [gem5-users] Question about compile after adding global funcs

2019-11-07 Thread Shougang Yuan
Hi, Francisco Carlos,

Thanks for your reply. I do add ifndef in mycode. I have added a lot
self-defined fucns before by adding the ifndef-define-endif. BUt this
morning, I always suffer from this error. The errors are as follows:

build/X86/mem/cache/lib.o.partial: In function `':
/home/syuan3/gem5/build/X86/mem/heap.hh:17: multiple definition of `'
build/X86/cpu/o3/lib.o.partial:/home/syuan3/gem5/build/X86/mem/heap.hh:17:
first defined here
collect2: error: ld returned 1 exit status
scons: *** [build/X86/gem5.opt] Error 1
scons: building terminated because of errors

Best regards.

Yuan

On Thu, Nov 7, 2019 at 9:52 AM Francisco Carlos 
wrote:

> Hi, Yuan
>
> Did you use #ifdef in your file my_func.hh?
>
> You should use #ifdef to avoid multiple definitions and circular includes.
>
> So, in the first line of your file my_func.hh, you must insert the
> following code:
>
> #ifndef _MEM_MY_FUNC_HH_
> #define  _MEM_MY_FUNC_HH_
>
> And in the last line of your file my_func.hh, you insert the code:
>
> #endif
>
>
> I think this should solve your problem.
>
>
> --
> Francisco Carlos Silva Junior
> PhD Student at University of Brasilia
>
>
> --
> *De:* gem5-users  em nome de yuan <
> syu...@ncsu.edu>
> *Enviado:* quinta-feira, 7 de novembro de 2019 11:28
> *Para:* gem5 users mailing list 
> *Assunto:* [gem5-users] Question about compile after adding global funcs
>
>
> Hi, All,
>
>
>
> I suffered one problem of multiple definition when compiling, what I did
> is adding some new functions I need in a file name my_func.hh under
> src/mem/, and in the file cache.cc where I need these functions I use
> #include “mem/my_func.hh”, but when I re-compile the gem5, it always shows
> the error of multiple definition of “the name of my func”. Does anyone have
> some hints on this?
>
>
>
> Best,
>
>
>
> Yuan
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
> ___
> gem5-users mailing list
> gem5-users@gem5.org
> http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
___
gem5-users mailing list
gem5-users@gem5.org
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Re: [gem5-users] Question about compile after adding global funcs

2019-11-07 Thread Francisco Carlos
Hi, Yuan

Did you use #ifdef in your file my_func.hh?

You should use #ifdef to avoid multiple definitions and circular includes.

So, in the first line of your file my_func.hh, you must insert the following 
code:

#ifndef _MEM_MY_FUNC_HH_
#define  _MEM_MY_FUNC_HH_

And in the last line of your file my_func.hh, you insert the code:

#endif


I think this should solve your problem.

--
Francisco Carlos Silva Junior
PhD Student at University of Brasilia



De: gem5-users  em nome de yuan 
Enviado: quinta-feira, 7 de novembro de 2019 11:28
Para: gem5 users mailing list 
Assunto: [gem5-users] Question about compile after adding global funcs


Hi, All,



I suffered one problem of multiple definition when compiling, what I did is 
adding some new functions I need in a file name my_func.hh under src/mem/, and 
in the file cache.cc where I need these functions I use #include 
“mem/my_func.hh”, but when I re-compile the gem5, it always shows the error of 
multiple definition of “the name of my func”. Does anyone have some hints on 
this?



Best,



Yuan



Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10


___
gem5-users mailing list
gem5-users@gem5.org
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

[gem5-users] Question about compile after adding global funcs

2019-11-07 Thread yuan
Hi, All,

I suffered one problem of multiple definition when compiling, what I did is 
adding some new functions I need in a file name my_func.hh under src/mem/, and 
in the file cache.cc where I need these functions I use #include 
“mem/my_func.hh”, but when I re-compile the gem5, it always shows the error of 
multiple definition of “the name of my func”. Does anyone have some hints on 
this?

Best,

Yuan

Sent from Mail for Windows 10

___
gem5-users mailing list
gem5-users@gem5.org
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users