-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix -Wstrict-prototype warnings in HalideRuntime.h #8027
Conversation
When HalideRuntime.h is included in a C file, funtions that are declared with `()` instead of `(void)` for their arguments change meaning. These may cause issues downstream because different code is generated. E.g., [godbolt link](https://godbolt.org/#z:OYLghAFBqd5TKALEBjA9gEwKYFFMCWALugE4A0BIEAZgQDbYB2AhgLbYgDkAjF%2BTXRMiAZVQtGIHgBYBQogFUAztgAKAD24AGfgCsp5eiyagA%2BudTkVjVEQJDqzTAGF09AK5smIAMw9yTgAyBEzYAHKeAEbYpCAArOQADuhKxPZMrh5evv7JqXZCwaERbNGxCdbYtukiRCykRJme3n5W2DYFTLX1REXhUTHxVnUNTdmtSiO9If2lg3EAlFbo7qSonFzY6kQxTADUIUR7gugQCwCkPgBC51oAgrd3Wzuk%2B4d7kfUQAG7oBJgXa6PR7vNgsEIQd71YCWPaoJD1ABUiL20O%2BCz25wA7Dd7nt8R8voDcXcCcd0KdiY8yaRsERVvstJcSdiACJcJb0bhxfjeLg6cjobjOPZKFZrbCYgBMfn4RG0HKWAGtfD4AHQ%2BTVa7XagBshm40n4bHiWnIfIFQq4/CUIDN8v5HPIcFgKAwOHwxDIlGodEYrA43D4cmEYgknBkIcUKg0CvI%2BilhmMoFQ5ylN3TbQ66UcTBcbmaOQCeb6JTKQzyaSEYxauRSVaYpYG5SzVU63VGBfG/kq1SEHemxWbQ0mPRrRdHDSbc3KSzFq3W3GeuwOwnJlOZwPuy9eq6On1IPz%2BAM39xBa7BEKhpBh5DhCNIyNRN/RmJx1IJB7Op9JBJO36BPECVpeldyZQCHixdlOW5Xk4ytZw0wzK5RXFdZpR8KU5QVBYliQbAWBwWIzgNLgjXIE04jNC1%2BCtG07XIB0dFw8gVSo0ifDgx1BW4bDHSWF0EHgCA3XQNhEgYGIfQgDBxMk2JUGAHhMIEBgXltCBIjjSIQnqABPIN%2BB01hSD0gB5SJdDbQzyFkjhhDMph6AM7icEidxgGcCR6FtXh%2BBwMETEkVyCFpapvmwXyBS2Kp3B2GzDnaGz6AISJSH01wcDjIhSAIE0/KWGgjGAJQADUCGwAB3MzEmYGzBFDcRJEjBrozUTRuP0fwjBMEBzFMSwUsiW1ICWdBEk6XzaIi0hcpwEaSN7Tpc3zLJvH8IIZjLQY63ydJx12htp3LHt2jbGopgO1s%2By6KZjp24Yxy7dbHqnLbhx4Oc0IjGCuB5c14O4PZ1AADl1ABaXVpD2GFUD2ZS1SlPYIE9EhSAwz6%2BOY5VTVI8jKOowHrSsBimKdQSRLQMSJMYCgqBk6n5JAJSVL9dTqC07jjP0mzudMiyrNsGy7OYIhHOcuM3I8rz6B8myAuTYKBUIMK7AiqL%2BBi1A4o2YNEq5PzDFS9LTMyjYBRyvLDMK4qyoq6rar5YNWrDZrZFa5R2rjBMk161N0yQo3hvgMaJvSKbBRmubIpD67logJwDsTTahxnKRDs6JOknrTp7tiHhTuzftLueqREyWi6ejz9PXsaUueHLu73rTguvoXTgpV%2B/6aJ4rhgbByHodh%2BH1SRlHCDRjDO6xxVyHwwjBhIg38dxnu6JJ%2B0cJx9iDc4gHuPXsmWINrD98tXjGK38gZtSBxpCAA%3D)
d4773d9
to
24831b7
Compare
Thanks for the fix |
I am deeply confused: how is it possible that |
Additionally, if we must standardize on one or the other, I would vastly prefer that we choose |
@steven-johnson they have identical meaning in C++ and C23 (and newer), but not in C11 and older versions of C. I guess the idea of HalideRuntime.h is to be usable from both C++ and C, hence the choice of |
OK, I see now, they are equivalent in C++ but officially-obsolescent-but-still-legal C means "any kind of args", sigh, sorry for the noise |
When HalideRuntime.h is included in a C file, funtions that are declared with `()` instead of `(void)` for their arguments change meaning. These may cause issues downstream because different code is generated.
When HalideRuntime.h is included in a C file, functions that are declared with
()
instead of(void)
for their arguments change meaning. These may cause issues downstream because different code is generated.E.g., godbolt example
This PR introduces aHALIDE_NO_ARGS
macro that expands to nothing orvoid
depending on whether the code is compiled in C++ or C mode. That way declarations such asfunction(HALIDE_NO_ARGS)
mean "functionfunction
receives no arguments" in both C++ and C.This PR replaces uses of
function()
withfunction(void)
sincefunction(void)
means "functionfunction
receives no arguments in both C++ and C"P.S. this issue was discovered when trying to use Halide with Chapel, but Chapel used
-Wstrict-prototypes
...