Skip to content

Fix Windows build error#663

Closed
ispointer wants to merge 5 commits intoJingMatrix:masterfrom
ispointer:master
Closed

Fix Windows build error#663
ispointer wants to merge 5 commits intoJingMatrix:masterfrom
ispointer:master

Conversation

@ispointer
Copy link
Copy Markdown

This pull request focuses on modernizing the native C++ code and improving the way string constants are handled across the project. I have updated the Gradle build scripts to use more reliable string escaping and introduced the V_TOSTR macro to safely manage preprocessor definitions like version names and package IDs. Additionally, I refactored several constants from old-style pointers to modern C++ features like inline constexpr and std::string_view, which makes the code faster and more memory-efficient. Along with these changes, I cleaned up the module logic by removing redundant keywords, adding necessary headers, and simplifying JNI comparisons to ensure better stability and maintainability for the entire module

@JingMatrix
Copy link
Copy Markdown
Owner

Two potential issues:

  1. Your new handling of string passing seems fragile to me, please explain why would you change it.
  2. https://en.cppreference.com/w/cpp/string/basic_string_view/data.html states that string_view data may not be null-terminated, and JNI is sensitive about it: https://docs.oracle.com/en/java/javase/11/docs/specs/jni/types.html#modified-utf-8-strings
    . Indeed, NewStringUTF takes a C-style pointer and expects MUTF-8, the underlying JVM implementation relies entirely on C's null-termination rule to find the end of the string.

@ispointer
Copy link
Copy Markdown
Author

ispointer commented Apr 13, 2026 via email

@ispointer
Copy link
Copy Markdown
Author

ispointer commented Apr 13, 2026 via email

@JingMatrix
Copy link
Copy Markdown
Owner

JingMatrix commented Apr 13, 2026

Okay, please also paste the Windows environment build error and warning for me to understand better the context.

If so, the main purpose of this PR should be to ensure Window compilation compatibility.

Copy link
Copy Markdown
Author

@ispointer ispointer left a comment

Choose a reason for hiding this comment

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

I have updated the constants from std::string_view back to const char* while maintaining the inline constexpr usage. This ensures that the strings are null-terminated, making them safe for JNI's NewStringUTF and resolving the potential memory issues. I also confirmed that these changes resolve the syntax issues during Windows builds. Please have a look

@ispointer ispointer changed the title Refactor string handling and modernize C++ codebase Fix Windows build error Apr 13, 2026
@ispointer
Copy link
Copy Markdown
Author

ispointer commented Apr 13, 2026

Screenshot 2026-04-14 041538

@ispointer ispointer closed this by deleting the head repository Apr 13, 2026
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

Successfully merging this pull request may close these issues.

2 participants