Software Archive
Read-only legacy content
17061 Discussions

Problem of multiple definition of fake_mutex

amina-jarraya
Beginner
539 Views
Hello,

I call the header file on my header file test.h to lock and unlock sections of code.
And in the file write.cpp, i need to lock and unlock sections of code too. so, i call the test.h file which call the fake_mutex.h.

but when compiling, i have the error of multiple definition `cilkscreen::create_fake_mutex()' as following :

...: In function `cilkscreen::create_fake_mutex()':
...: multiple definition of `cilkscreen::create_fake_mutex()'
...:/home/amina/projet/cilkplus-install/include/cilktools/fake_mutex.h:79: first defined here
....

How can i have one copy of fake_mutex to avoid the problem of multiple definition ?

Thank you in advance,
0 Kudos
1 Solution
Barry_T_Intel
Employee
539 Views

I believe that adding the "inline" attribute to the declaration in fake_mutex.h will fix your problem. Here's the modified code:

    // Factory function for fake mutex
    inline fake_mutex *CILKSCREEN_CDECL create_fake_mutex() { return new fake_mutex(); }

    // Destructor function for fake mutex - The mutex cannot be used after
    // calling this function
    inline void CILKSCREEN_CDECL destroy_fake_mutex(fake_mutex *m) { delete m; }

- Barry

View solution in original post

0 Kudos
5 Replies
Barry_T_Intel
Employee
539 Views
Which OS are you working on?

- Barry
0 Kudos
amina-jarraya
Beginner
539 Views
i'm working on ubunto 10.04

amina@amina-laptop:~/projet/cilkplus-install/examples/princeFGTest$ uname -a
Linux amina-laptop 2.6.32-37-generic #81-Ubuntu SMP Fri Dec 2 20:35:14 UTC 2011 i686 GNU/Linux

0 Kudos
Barry_T_Intel
Employee
540 Views

I believe that adding the "inline" attribute to the declaration in fake_mutex.h will fix your problem. Here's the modified code:

    // Factory function for fake mutex
    inline fake_mutex *CILKSCREEN_CDECL create_fake_mutex() { return new fake_mutex(); }

    // Destructor function for fake mutex - The mutex cannot be used after
    // calling this function
    inline void CILKSCREEN_CDECL destroy_fake_mutex(fake_mutex *m) { delete m; }

- Barry

0 Kudos
amina-jarraya
Beginner
539 Views
It works fine

Thank you,
0 Kudos
Barry_T_Intel
Employee
539 Views
Thanks for the confirmation. I've updated the sources.

- Barry
0 Kudos
Reply