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

Remove designated array initializers in rz_analysis.h #3876

Merged
merged 3 commits into from
Sep 25, 2023
Merged

Conversation

DMaroo
Copy link
Member

@DMaroo DMaroo commented Sep 20, 2023

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the rizin book with the relevant information (if needed)

Detailed description

Removed designated array initializers from the code. MSVC C++ compiler seems to not be able to compile it since it is a C99 thing, and MSVC C++ does not entirely support C99.

MCVE: https://godbolt.org/z/af3v7rWfh.

Also added a new test in Appveyor for testing inclusion of Rizin headers in C++ files. The test is only enabled for VS2022.

Test plan

The new CI for compiling the Rizin headers included in a C++ passes succesfully, and green CI.

Closing issues

Fixes the build for rizinorg/cutter#3247.

(Ignore the branch name)

Sorry, something went wrong.

@DMaroo DMaroo requested a review from wargio September 20, 2023 14:24
Copy link
Member

@XVilka XVilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is the right fix...
It's better to fix the MSVC C++ compilation of the rz_analysis.h instead.

@XVilka
Copy link
Member

XVilka commented Sep 20, 2023

The culprit seems to be in this code: minimal example on Compiler Explorer

@DMaroo
Copy link
Member Author

DMaroo commented Sep 20, 2023

Discussion continued on Mattermost: https://im.rizin.re/rizinorg/pl/4gn8eymqupbtjnr9rahd1stzwc.

@XVilka
Copy link
Member

XVilka commented Sep 22, 2023

Please undo the split and fix the MSVC build, preferably with adding MSVC C++ CI job too, then we can merge.

@DMaroo DMaroo force-pushed the split-rz-analysis-op branch from 125fd68 to af27b59 Compare September 22, 2023 09:37
@DMaroo DMaroo changed the title Split RzAnalysisOpType in a different file Remove designeated array initializers, and add a MSVC CI Sep 22, 2023
@DMaroo DMaroo changed the title Remove designeated array initializers, and add a MSVC CI Remove designated array initializers, and add a MSVC CI Sep 22, 2023
Copy link
Member

@XVilka XVilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format complains:

Formatting [1277/1629] librz/include/rz_analysis.h
librz/include/rz_analysis.h:717:26: error: code should be clang-formatted [-Wclang-format-violations]
        RZ_ANALYSIS_VAR_KIND_END  ///< Number of RzAnalysisVarKind enums
                                ^
librz/include/rz_analysis.h:734:28: error: code should be clang-formatted [-Wclang-format-violations]
        RZ_ANALYSIS_VAR_ORIGIN_END  ///< Number of RzAnalysisVarOriginKind enums
                                  ^

@DMaroo DMaroo marked this pull request as draft September 22, 2023 12:27
@DMaroo DMaroo changed the title Remove designated array initializers, and add a MSVC CI Remove designated array initializers in rz_analysis.h Sep 22, 2023
@DMaroo
Copy link
Member Author

DMaroo commented Sep 22, 2023

Will remove the draft status after the PR for adding the CI gets merged.

@XVilka
Copy link
Member

XVilka commented Sep 22, 2023

Will remove the draft status after the PR for adding the CI gets merged.

What PR?

@DMaroo
Copy link
Member Author

DMaroo commented Sep 22, 2023

I'm working on it 😅

@XVilka
Copy link
Member

XVilka commented Sep 25, 2023

Will remove the draft status after the PR for adding the CI gets merged.

To be honest, I think it's better to add the CI job in the same PR since it will be red on the dev anyway. Just fix the syntax and add CI in this PR, it will be fine.

@DMaroo
Copy link
Member Author

DMaroo commented Sep 25, 2023

Alright, makes sense!

    * Need to test whether Rizin headers can be included in C++ when
      using MSVC, needed for Cutter to build successfully
    * Changed the name of `build-cpp` CI job in GitHUb jobs to
      `build-cpp-linux` to make it obvious that it only performs the
      test for Linux
@DMaroo DMaroo force-pushed the split-rz-analysis-op branch from 4dd63d4 to 6ae791b Compare September 25, 2023 18:34
@DMaroo
Copy link
Member Author

DMaroo commented Sep 25, 2023

I have only enabled the C++ build test for VS2022, should I also enable it for clang-cl?

@DMaroo DMaroo requested a review from XVilka September 25, 2023 19:37
@DMaroo DMaroo marked this pull request as ready for review September 25, 2023 19:37
@XVilka XVilka merged commit 714c338 into dev Sep 25, 2023
ret2libc pushed a commit that referenced this pull request Sep 27, 2023
* Do not use designater array initializer because MSVC complains
* Add new Appveyor CI test for including C headers from C++ files

    * Need to test whether Rizin headers can be included in C++ when
      using MSVC, needed for Cutter to build successfully
    * Changed the name of `build-cpp` CI job in GitHUb jobs to
      `build-cpp-linux` to make it obvious that it only performs the
      test for Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants