Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy constructor on std::mutex #2701

Closed
jcyuan opened this issue Oct 21, 2023 · 2 comments
Closed

copy constructor on std::mutex #2701

jcyuan opened this issue Oct 21, 2023 · 2 comments

Comments

@jcyuan
Copy link

jcyuan commented Oct 21, 2023

the generated wrapper class has a lot of this error:

SWIGEXPORT void SWIGSTDCALL CSharp_pag_Layer_Locker_set(void * jarg1, void * jarg2) {
  pag::Layer *arg1 = (pag::Layer *) 0 ;
  std::mutex arg2 ;
  std::mutex *argp2 ;
  
  arg1 = (pag::Layer *)jarg1; 
  argp2 = (std::mutex *)jarg2; 
  if (!argp2) {
    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null std::mutex", 0);
    return ;
  }
  arg2 = *argp2;      // <---------------------------- this C2280
  if (arg1) (arg1)->locker = arg2;
}

copy/move is not allowed for std::mutex, so in this case what is the elegant / common way for my i file to fix this compiling error? (because i can't modify the 3rd project headers)

thanks so much.

@jcyuan
Copy link
Author

jcyuan commented Oct 21, 2023

ah, right, by the way another question is,
edited, deleted, please use one issue per question

@wsfulton
Copy link
Member

An api with a std::mutex that is not copyable, assignable nor movable is not usable. You'll have to use %ignore on the methods that expect an instance of std::mutex to be passed by vaule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants