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

Error when compiling with MinGW due to usage of MS-specific __except keyword #3586

Closed
Rush opened this issue Jul 17, 2019 · 5 comments · Fixed by #3601
Closed

Error when compiling with MinGW due to usage of MS-specific __except keyword #3586

Rush opened this issue Jul 17, 2019 · 5 comments · Fixed by #3601

Comments

@Rush
Copy link

Rush commented Jul 17, 2019

Please use this template for reporting suspected bugs or requests for help.

Issue description

Trying to compile libzmq with MinGW - the issue is fairly obvious. __except should not have gone through a code review as it's a Microsoft specific extension.

https://github.com/zeromq/libzmq/blame/aac3cd4d93d288b29b71806c2478a947d66238b6/src/thread.cpp#L136

src/thread.cpp:128: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(push)                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                             
src/thread.cpp:129: warning: ignoring #pragma warning  [-Wunknown-pragmas]                                                                                                                                                                                   
 #pragma warning(disable : 6320 6322)                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                             
src/thread.cpp:138: warning: ignoring #pragma warning  [-Wunknown-pragmas]                                                                                                                                                                                   
 #pragma warning(pop)                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                             
src/thread.cpp: In member function 'void zmq::thread_t::applyThreadName()':                                                                                                                                                                                  
src/thread.cpp:136:5: error: expected 'catch' before '__except'                                                                                                                                                                                              
     __except (EXCEPTION_CONTINUE_EXECUTION) {                                                                                                                                                                                                               
     ^~~~~~~~                                                                                                                                                                                                                                                
src/thread.cpp:136:5: error: expected '(' before '__except'                                                                                                                                                                                                  
     __except (EXCEPTION_CONTINUE_EXECUTION) {                                                                                                                                                                                                               
     ^~~~~~~~                                                                                                                                                                                                                                                
     (                                                                                                                                                                                                                                                       
src/thread.cpp:136:5: error: expected type-specifier before '__except'                                                                                                                                                                                       
     __except (EXCEPTION_CONTINUE_EXECUTION) {                                                                                                                                                                                                               
     ^~~~~~~~                                                                                                                                                                                                                                                
src/thread.cpp:136:13: error: expected ')' before '(' token                                                                                                                                                                                                  
     __except (EXCEPTION_CONTINUE_EXECUTION) {                                                                                                                                                                                                               
     ~~~~~~~~^~                                                                                                                                                                                                                                              
             )                                                                                                                                                                                                                                               
src/thread.cpp:136:14: error: expected '{' before '(' token                                                                                                                                                                                                  
     __except (EXCEPTION_CONTINUE_EXECUTION) {                                                                                                                                                                                                               
              ^                                                                                                                                                                                                                                              
src/thread.cpp:136:44: error: expected ';' before '{' token                                                                                                                                                                                                  
     __except (EXCEPTION_CONTINUE_EXECUTION) {                                                                                                                                                                                                               
                                            ^~                                                                                                                                                                                                               
                                            ;                          

Environment

  • libzmq version (commit hash if unreleased):
  • OS: Docker / openSUSE Leap 15.1

Minimal test code / Steps to reproduce the issue

Can provide a Dockerfile upon request.

@bluca
Copy link
Member

bluca commented Jul 18, 2019

Interesting that the mingw build test did not catch this:

https://ci.appveyor.com/project/zeromq/libzmq/builds/26024001/job/cp8r6o28y931toy2

Could you please send a PR to fix it?

@Rush
Copy link
Author

Rush commented Jul 18, 2019

@bluca Sorry, it's obvious why it doesn't compile but I am not a ZeroMQ contributor and not entirely sure why __except was used so can't say I know the right fix.

Fortunately it worked fine with the previous version 4.3.1 and only 4.3.2 is broken.

I can give the fix fix a try if no other person shows up Perhaps the original author @moretromain could give this a shot?

I'll be happy to test.

@TomzBench
Copy link

TomzBench commented Aug 9, 2019

Not sure if this is related. But I get this error when on "latest_release" branch. So when switching to master and compiling with mingw I get the error below because it does not like storing a function pointer into a (void*)

C:\...\libzmq\src\thread.cpp:150: error: invalid conversion from 'int (*)(EXCEPTION_RECORD*, void*, CONTEXT*, void*) {aka int (*)(_EXCEPTION_RECORD*, void*, _CONTEXT*, void*)}' to 'void*' [-fpermissive] rec.Handler = continue_execution; ^~~~~~~~~~~~~~~~~~

@bluca
Copy link
Member

bluca commented Aug 10, 2019

Could you please send a PR to fix it?

@jakecobb
Copy link
Contributor

jakecobb commented Feb 11, 2021

I suspect this change has caused a crash under OpenCppCoverage with Visual Studio builds starting in ZeroMQ 4.3.3:

OpenCppCoverage/OpenCppCoverage#141

MarijnS95 added a commit to Traverse-Research/zeromq-src-rs that referenced this issue Feb 3, 2022
jean-airoldie pushed a commit to jean-airoldie/zeromq-src-rs that referenced this issue Feb 14, 2022
* Strip cmake
* Update zmq to 4.3.4 to solve zeromq/libzmq/issues/3586
* Switch to github actions for all CI
* Add libsodium test
* Remove perftools
* Remove static feature

Co-authored-by: Marijn Suijten <marijn@traverseresearch.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants