Skip to content

Commit

Permalink
MSVC only
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed May 20, 2024
1 parent dad1e54 commit dcbd291
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@ typedef HRESULT (__stdcall *ValidateJson)(uintptr_t handle, char const* value, s
typedef void (__stdcall *CloseJsonValidator)(uintptr_t handle);

extern "C" {
void __stdcall CoTaskMemFree(void* ptr);

void __stdcall client() {
auto library = LoadLibraryExW(L"sample_component_json_validator.dll", 0, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
assert(library != 0);

auto create = (CreateJsonValidator)GetProcAddress(library, "CreateJsonValidator");
auto create = reinterpret_cast<CreateJsonValidator>(GetProcAddress(library, "CreateJsonValidator"));
assert(create);

auto validate = (ValidateJson)GetProcAddress(library, "ValidateJson");
auto validate = reinterpret_cast<ValidateJson>(GetProcAddress(library, "ValidateJson"));
assert(validate);

auto close = (CloseJsonValidator)GetProcAddress(library, "CloseJsonValidator");
auto close = reinterpret_cast<CloseJsonValidator>(GetProcAddress(library, "CloseJsonValidator"));
assert(close);

std::string_view schema = "{\"maxLength\": 5}";
Expand Down
2 changes: 2 additions & 0 deletions crates/samples/components/json_validator_client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(target_env = "msvc")]

#[test]
fn test() {
extern "system" {
Expand Down

0 comments on commit dcbd291

Please sign in to comment.