relacy icon indicating copy to clipboard operation
relacy copied to clipboard

resolve std name conflict

Open ghost opened this issue 8 years ago • 6 comments

Due to forward declarations and the structure of std includes I had compiler warning for redeclaring some atomic structures. Here is a possible solution using defines and an internal namespace in std.

ghost avatar Jun 03 '16 23:06 ghost

What compiler are you using? And what warnings does it produce?

dvyukov avatar Jun 05 '16 10:06 dvyukov

I had some std header included (vector, string) and on Visual Studio 2015 it was complaining about the memory_order: error C2874: using-declaration causes a multiple declaration of 'rl::memory_order'. The include hierarchy was something like: vector included xmemory which included xatomic.

On GCC (5, the current mainstream gcc compiler on ubuntu) it had a similar problem with the atomic. I have not checked that.

ghost avatar Jun 06 '16 07:06 ghost

It was a fast search/replace and did not considered any other name conflict. I know it's not the best solution but had no better idea. The best would be to pretend that atomic, thread, mutex, etc. has already been included, but I doubt if it has a solution independent of the implementation of libstd.

Note, I had the define problem with delete too.

class Foo {
  Foo(const Foo&) = delete;
}

ghost avatar Jun 06 '16 15:06 ghost

It was a fast search/replace and did not considered any other name conflict.

So does mutex lead to the same problems or not?

Foo(const Foo&) = delete;

Just don't use this with Relacy. Define-based instrumentation sucks, it all needs to be redone to use compiler instrumentation. But I don't have time for that.

dvyukov avatar Jun 06 '16 15:06 dvyukov

mutex was ok, did not have the problem. Unfortunatelly I forget to create a branch before push/PR. So I'll close the PR and create a new branch. Are u interested in the patch ? Shall I resend the PR from the new branch?

ghost avatar Jun 08 '16 15:06 ghost

Unfortunatelly I forget to create a branch before push/PR. So I'll close the PR and create a new branch.

git push -f?

Are u interested in the patch ?

Yes. It fixes build for you, right? Without mutex/condvar changes it looks good to me.

Thanks

dvyukov avatar Jun 09 '16 14:06 dvyukov