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

lib: Fix compile errors on C and warnings on C++ #1194

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

norihiro
Copy link
Contributor

@norihiro norihiro commented Dec 31, 2023

Description

Fix compile errors and warnings in lib/obs-websocket-api.h so that the file can be included from both C and C++ code.

Motivation and Context

Using C++ on GCC, there was warnings below. We need to add remaining initializers.

lib/obs-websocket-api.h:56:27: warning: missing initializer for member ‘calldata::size’ [-Wmissing-field-initializers]
   56 |         calldata_t cd = {0};
      |                           ^

Using C on Clang,

obs-websocket-api.h:47:1: error: 'inline' can only appear on functions inline proc_handler_t *_ph;
obs-websocket-api.h:107:15: error: must use 'struct' tag to refer to type 'obs_websocket_request_response'
static inline obs_websocket_request_response *obs_websocket_call_request(const char *request_type, obs_data_t *request_data = NULL)
              ^
              struct 

obs-websocket-api.h:107:125: error: C does not support default arguments
static inline obs_websocket_request_response *obs_websocket_call_request(const char *request_type, obs_data_t *request_data = NULL)
                                                                                                                            ^ ~~~~
obs-websocket-api.h:123:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
        auto ret = (struct obs_websocket_request_response *)calldata_ptr(&cd, "response");
        ~~~~ ^

Using C on VC++,

obs-websocket-api.h(173,46): error C2059: syntax error: '}' 

How Has This Been Tested?

Tested OS(s): Both C and C++ compilations are tested on Fedora 38, macOS 12, Windows 2022, Ubuntu 22.04.

Types of changes

Checklist:

  • I have read the Contributing Guidelines.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • My code is not on master or a release/* branch.
  • The code has been tested.
  • I have included updates to all appropriate documentation.

@norihiro norihiro force-pushed the fix-api-header-compile-errors branch from 815c1a4 to df745fa Compare December 31, 2023 21:32
@tt2468
Copy link
Member

tt2468 commented Jan 16, 2024

I see the checklist hasn't been touched, is this ready to be merged?

@norihiro
Copy link
Contributor Author

norihiro commented Jan 16, 2024

I'm sorry, I have forgot the checklist. Now all the items are checked.
I used clang-format version 16.0.6 to check the code format. I hope this should be fine.

@tt2468 tt2468 merged commit 6c67b27 into obsproject:master Jan 16, 2024
1 check passed
@norihiro norihiro deleted the fix-api-header-compile-errors branch January 16, 2024 16:43
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