-
Notifications
You must be signed in to change notification settings - Fork 264
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
Macro named '_FillValue' conflicts with libc++ headers #2858
Comments
The original _FillValue macro was, in hindsight, a mistake and should have had some tag such as NC_FillValue. |
Do you expect any external netcdf.h consumers to use the (In FreeBSD's port system there are about 300 ports that depend on netcdf, so I have asked for a test-run with the macro renamed. We'll see how many of these other programs fail to build.) |
The problem is that netcdf.h is the embodiment of the API for the netcdf library. |
I think an argument can be made that we should just change it so that we're actually compatible with C99. The spec specifically says:
|
And you can find all violations of this rule with clang's -Wreserved-identifier warning flag. |
I agree with @dopplershift that it should just be changed. Sure, some user might be using the macro, but if so, they will discover the problem at their next compile, and it's trivial for them to fix it. I suggest just change it, put it in the release notes, and move on. It can just be commented out in the file, and then if the user is using it, and wants to uncomment it as a temp fix, that would be easy. |
@DennisHeimbigner While I agree that changing API surface is always tricky, in this case NetCDF is using a reserved identifier and that's causing way more harm than the migration of your own users to the new API. For example, it could have easily been the case that your library simply doesn't build anymore when using a recent version of Clang, which effectively means that it wouldn't build anymore on FreeBSD, Android, Apple platforms and others who use that compiler. That would be way worse for your users than just migrating to a new macro for the subset of users impacted. Respecting standard conventions is important for the ecosystem, and I would really encourage you to get started with this migration -- it's often easier than we think. We do a lot of these kinds of migrations in libc++ and it always works out even though it creates a bit of work for some folks -- that's unavoidable. |
Ok, then let's do this in steps.
I realize that this is slower than is desirable because it takes two released to finally remove _FillValue. |
Personally, I think this is a perfectly fine timeline and approach to do this. If we were deprecating something in libc++, that's how I would do it (and that's what we often do) -- it's normal to take some time to do these things. |
I'm +0.5 on skipping deprecation and just documenting in release notes since:
With that said, I'm not on the hook to deal with support on this, so I completely defer. |
I suspect we should be able to refactor this out, while leaving the name of attribute alone (as we'd expect). Tagging this for the upcoming release, it should (ideally) be pretty straightforward, but if it's not, we can reconsider our approach. |
Taking a look to see if I can do this refactor before the v4.9.3 release |
* main: (48 commits) Update release notes. Refactor macro _FillValue to NC_FillValue in support of Unidata#2858 Remove appveyor config file. Add CI for a Windows Runner on Github Actions. Add cmake prefix path to appveyor config. Attempt to fix zlib-related error in appveyor. Correct typo. Remove check for libcurl unless it is necessary for required functionality. Rename the vendored strlcat symbol Fix conversion warnings in libdispatch Set flags to avoid warning messages if curl isn't found. Use modern cmake nomenclature for curl. Fix truncated-format warning in ncgen Fix some conversion warnings in ncgen3 Fix some conversion warnings in ncgen3 generated files Regenerate ncgen3 CMake: Add option to automatically regenerate ncgen3/ncgen Skip checking for duplicates if only one element in list Change format of backwards-loops Silence some conversion warnings in ncgen generated files ...
* main: (158 commits) Update release notes. Refactor macro _FillValue to NC_FillValue in support of Unidata#2858 Remove appveyor config file. Add CI for a Windows Runner on Github Actions. Add cmake prefix path to appveyor config. Attempt to fix zlib-related error in appveyor. Correct typo. Remove check for libcurl unless it is necessary for required functionality. Rename the vendored strlcat symbol Fix conversion warnings in libdispatch Set flags to avoid warning messages if curl isn't found. Use modern cmake nomenclature for curl. Fix truncated-format warning in ncgen Fix some conversion warnings in ncgen3 Fix some conversion warnings in ncgen3 generated files Regenerate ncgen3 CMake: Add option to automatically regenerate ncgen3/ncgen Skip checking for duplicates if only one element in list Change format of backwards-loops Silence some conversion warnings in ncgen generated files ...
This is a report of a problem encountered when building the science/netcdf-cxx port on FreeBSD, against libc++ 18 headers. The reason I am filing an issue in this project instead, is that the actual error is caused by a problem in the
netcdf.h
header, which is included from netcdf-cxx.When you attempt to build netcdf-cxx against installed netcdf-c headers, several compile errors are produced, similar to:
The problem is that
_FillValue
is a macro defined innetcdf.h
, but it conflicts with a template parameter name in libc++'s__bit_reference
header. In general, identifiers starting with_
are reserved for the system headers, so in my opinionnetcdf.h
should be adjusted.However, it looks like the macro name itself is used in a lot of places in netcdf itself, and possibly also in derived projects such as netcdf-cxx. Therefore, I would like to ask you how much breakage would be expected, if the macro name was changed to, for example,
NC_FillValue
?For reference, the FreeBSD science/netcdf port is at version 4.9.2, while the science/netcdf-cxx port is at version 4.3.1, but the problem is also present in the current main branch of this project.
The text was updated successfully, but these errors were encountered: