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

Compiler warnings: formal parameter different from declaration #1512

Closed
bo-ms opened this issue Nov 13, 2020 · 11 comments · Fixed by #1517
Closed

Compiler warnings: formal parameter different from declaration #1512

bo-ms opened this issue Nov 13, 2020 · 11 comments · Fixed by #1517
Assignees

Comments

@bo-ms
Copy link

bo-ms commented Nov 13, 2020

I got following compiler warnings in Visual Stuido 2019. For example: the parameter parent in az_context_create_with_expiration() with different declarations in.c/.h

In_ az_context.h https://github.com/Azure/azure-sdk-for-c/blob/master/sdk/inc/azure/core/az_context.h#L65
image

In az_context.c https://github.com/Azure/azure-sdk-for-c/blob/master/sdk/src/azure/core/az_context.c#L58
image

Log:

1>------ Build started: Project: az_core, Configuration: Debug WIN32 ------
1>az_context.c
1>az_http_policy_logging.c
1>az_http_request.c
1>az_json_reader.c
1>az_json_token.c
1>az_json_writer.c
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_context.c(59,1): error C2220: warning treated as error - no 'object' file generated
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_context.c(59,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_context.c(70,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_context.c(88,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_token.c(44,1): error C2220: warning treated as error - no 'object' file generated
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_token.c(44,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_token.c(154,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_reader.c(18,1): error C2220: warning treated as error - no 'object' file generated
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_reader.c(18,1): warning C4028: formal parameter 3 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_reader.c(56,1): warning C4028: formal parameter 4 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_token.c(248,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_token.c(334,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_token.c(434,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_token.c(469,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_http_policy_logging.c(211,1): error C2220: warning treated as error - no 'object' file generated
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_writer.c(19,1): error C2220: warning treated as error - no 'object' file generated
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_http_policy_logging.c(211,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_writer.c(19,1): warning C4028: formal parameter 3 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_http_request.c(156,1): error C2220: warning treated as error - no 'object' file generated
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_writer.c(44,1): warning C4028: formal parameter 5 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_http_request.c(156,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_http_request.c(177,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_http_request.c(188,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_token.c(504,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_http_policy_logging.c(224,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_http_request.c(199,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_http_policy_logging.c(224,1): warning C4028: formal parameter 3 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_http_request.c(208,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_token.c(539,1): warning C4028: formal parameter 1 different from declaration
1>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\core\az_json_token.c(574,1): warning C4028: formal parameter 1 different from declaration
1>Done building project "az_core.vcxproj" -- FAILED.
2>------ Build started: Project: az_iot_hub, Configuration: Debug WIN32 ------
3>------ Build started: Project: az_iot_provisioning, Configuration: Debug WIN32 ------
2>az_iot_hub_client.c
3>az_iot_provisioning_client.c
3>az_iot_provisioning_client_sas.c
2>az_iot_hub_client_sas.c
2>az_iot_hub_client_telemetry.c
2>az_iot_hub_client_c2d.c
2>az_iot_hub_client_twin.c
2>az_iot_hub_client_methods.c
3>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_provisioning_client_sas.c(38,1): error C2220: warning treated as error - no 'object' file generated
3>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_provisioning_client_sas.c(38,1): warning C4028: formal parameter 1 different from declaration
3>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_provisioning_client_sas.c(79,1): warning C4028: formal parameter 1 different from declaration
3>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_provisioning_client.c(55,1): error C2220: warning treated as error - no 'object' file generated
3>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_provisioning_client.c(55,1): warning C4028: formal parameter 5 different from declaration
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_sas.c(41,1): error C2220: warning treated as error - no 'object' file generated
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_sas.c(41,1): warning C4028: formal parameter 1 different from declaration
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_sas.c(91,1): warning C4028: formal parameter 1 different from declaration
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_c2d.c(23,1): error C2220: warning treated as error - no 'object' file generated
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_c2d.c(23,1): warning C4028: formal parameter 1 different from declaration
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_twin.c(36,1): error C2220: warning treated as error - no 'object' file generated
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_twin.c(36,1): warning C4028: formal parameter 1 different from declaration
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_twin.c(76,1): warning C4028: formal parameter 1 different from declaration
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_twin.c(114,1): warning C4028: formal parameter 1 different from declaration
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_telemetry.c(26,1): error C2220: warning treated as error - no 'object' file generated
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_telemetry.c(26,1): warning C4028: formal parameter 1 different from declaration
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_telemetry.c(26,1): warning C4028: formal parameter 2 different from declaration
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client.c(39,1): error C2220: warning treated as error - no 'object' file generated
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client.c(39,1): warning C4028: formal parameter 4 different from declaration
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client.c(56,1): warning C4028: formal parameter 1 different from declaration
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client.c(139,1): warning C4028: formal parameter 1 different from declaration
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_methods.c(28,1): error C2220: warning treated as error - no 'object' file generated
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_methods.c(28,1): warning C4028: formal parameter 1 different from declaration
3>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_provisioning_client.c(77,1): warning C4028: formal parameter 1 different from declaration
3>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_provisioning_client.c(130,1): warning C4028: formal parameter 1 different from declaration
3>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_provisioning_client.c(160,1): warning C4028: formal parameter 1 different from declaration
3>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_provisioning_client.c(195,1): warning C4028: formal parameter 1 different from declaration
3>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_provisioning_client.c(516,1): warning C4028: formal parameter 1 different from declaration
3>Done building project "az_iot_provisioning.vcxproj" -- FAILED.
2>D:\code\netx\netxduo\addons\azure_iot\azure-sdk-for-c\sdk\src\azure\iot\az_iot_hub_client_methods.c(86,1): warning C4028: formal parameter 1 different from declaration
2>Done building project "az_iot_hub.vcxproj" -- FAILED.
4>------ Build started: Project: sample_azure_iot_embedded_sdk_pnp, Configuration: Debug WIN32 ------
4>main.c
4>sample_azure_iot_embedded_sdk_pnp.c
4>sample_device_identity.c
4>nx_azure_iot_cert.c
4>nx_azure_iot_ciphersuites.c
4>sample_azure_iot_embedded_sdk_pnp.vcxproj -> D:\code\netx\Test\Regression\azure_iot\project\cmake\build\Debug\sample_azure_iot_embedded_sdk_pnp.exe
========== Build: 1 succeeded, 3 failed, 7 up-to-date, 0 skipped ==========

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Nov 13, 2020
@danewalton danewalton self-assigned this Nov 13, 2020
@danewalton
Copy link
Member

@ahsonkhan didn't we decide to do away with right side const? There are several other places where we still have them in .c files.

@ahsonkhan
Copy link
Member

I am fine with reverting #1261 and not have the right hand const even in source .c files so that the header and source match. We certainly don't want them in the .h file.

@ahsonkhan
Copy link
Member

ahsonkhan commented Nov 13, 2020

That said, the warning from MSVC is somewhat incorrect as it is flagging something that the standard (and other compilers) allow.

@antkmsft
Copy link
Member

New MSVC versions shouldn't warn, but old versions are still around. The bug was fixed less than a year ago, IIRC.

@danewalton
Copy link
Member

I addressed this and other right hand const on parameters in APIs in the above PR. Let me know y'alls thoughts.

@ahsonkhan
Copy link
Member

@bo-ms, what version of VS 2019 are you on (I am on Version 16.8.0 Preview 1.0)? Can you try upgrading and see if the issue is still reproducible?

@ahsonkhan ahsonkhan added this to the [2020] December milestone Nov 14, 2020
@ahsonkhan ahsonkhan added Azure.Core IoT and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Nov 14, 2020
@bo-ms
Copy link
Author

bo-ms commented Nov 16, 2020

@danewalton #1517 fixed the compiler warning, could you apply it into feature/iot_pnp branch? thanks.

@bo-ms
Copy link
Author

bo-ms commented Nov 16, 2020

@bo-ms, what version of VS 2019 are you on (I am on Version 16.8.0 Preview 1.0)? Can you try upgrading and see if the issue is still reproducible?

@ahsonkhan I am on Visual Studio Enterprise 2019 version 16.2.0, and there is no warning in new version (16.8.1).

@ahsonkhan
Copy link
Member

OK, that's good to know. Thanks for confirming. Looks like the workaround for MSVC issue isn't absolutely necessary then. Correct me if I am wrong, but that means doing a one-off port of the commit from master isn't necessary atm.

The change will get picked up whenever master is merged into the feature branch. Up to @danewalton when to do that, or to group them later, closer to the next release.

@danewalton
Copy link
Member

I don't think there is harm in merging master changes into the feature branch on a regular basis. It honestly makes the merge changes easier to manage instead of one monolith near release times.

@danewalton
Copy link
Member

tackled in #1520

@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.