Add void to empty parameter list to fix -Werror=strict-prototypes error - #26016
Merged
Merged
Conversation
edgchen1
reviewed
Sep 12, 2025
Compiling C application dependent on onnxruntime with flag -Werror=strict-prototypes flag results in an error because the function declarations without parameters are considered to have an implicit int parameter list, which is not allowed in strict prototype mode. To fix this, we need to explicitly specify void in the parameter list of functions that do not take any arguments. Signed-off-by: Lifang Zhang <lifang.zhang@nokia.com>
lifang-zhang
force-pushed
the
fix-strict-prototype-error
branch
from
September 15, 2025 06:51
e337c88 to
b55f954
Compare
Contributor
|
/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline |
|
Azure Pipelines successfully started running 4 pipeline(s). |
edgchen1
approved these changes
Sep 17, 2025
Contributor
|
thanks for the PR! |
naomiOvad
pushed a commit
to naomiOvad/onnxruntime
that referenced
this pull request
Nov 2, 2025
…or (microsoft#26016) Compiling C application dependent on onnxruntime with flag -Werror=strict-prototypes results in an error because the function declarations without parameters are considered to have an implicit int parameter list, which is not allowed in strict prototype mode. To fix this, we need to explicitly specify void in the parameter list of functions that do not take any arguments. ### Description <!-- Describe your changes. --> ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> When compiling a C program that depends on ONNX Runtime with the `-Werror=strict-prototypes` flag enabled, the build fails due to function declarations in `onnxruntime_c_api.h` that are not strict prototypes. For example, in the **onnxruntime-inference-examples** project, the following errors are reported: ``` ~/install/onnxruntime/include/onnxruntime_c_api.h:4929:3: error: function declaration isn't a prototype [-Werror=strict-prototypes] const OrtModelEditorApi*(ORT_API_CALL* GetModelEditorApi)(); ^~~~~ ~/install/onnxruntime/include/onnxruntime_c_api.h:4987:3: error: function declaration isn't a prototype [-Werror=strict-prototypes] const OrtCompileApi*(ORT_API_CALL* GetCompileApi)(); ^~~~~ ~/install/onnxruntime/include/onnxruntime_c_api.h:5253:3: error: function declaration isn't a prototype [-Werror=strict-prototypes] const OrtEpApi*(ORT_API_CALL* GetEpApi)(); ^~~~~ ``` This occurs because function declarations with empty parentheses are not considered proper prototypes in C, and strict prototype checking treats this as an error. Our project uses ONNX Runtime and enforces -Werror=strict-prototypes in our build system. It would be very helpful if these declarations in ONNX Runtime could be updated to use (void) for functions that take no arguments, so that strict prototype builds succeed without errors. Signed-off-by: Lifang Zhang <lifang.zhang@nokia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compiling C application dependent on onnxruntime with flag -Werror=strict-prototypes results in an error because the function declarations without parameters are considered to have an implicit int parameter list, which is not allowed in strict prototype mode. To fix this, we need to explicitly specify void in the parameter list of functions that do not take any arguments.
Description
Motivation and Context
When compiling a C program that depends on ONNX Runtime with the
-Werror=strict-prototypesflag enabled, the build fails due to function declarations inonnxruntime_c_api.hthat are not strict prototypes. For example, in the onnxruntime-inference-examples project, the following errors are reported:This occurs because function declarations with empty parentheses are not considered proper prototypes in C, and strict prototype checking treats this as an error.
Our project uses ONNX Runtime and enforces -Werror=strict-prototypes in our build system. It would be very helpful if these declarations in ONNX Runtime could be updated to use (void) for functions that take no arguments, so that strict prototype builds succeed without errors.