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

Isolate code depending on v2 API #656

Closed
wants to merge 3 commits into from

Conversation

gsjaardema
Copy link
Contributor

There are two code segments using the v2 API. One was protected by NO_NETCDF_2 ifdef, but that isn't defined in the CMake build. Better to use the NC_HAS_NC2 define which is in netcdf_meta.h

The second code segment was not protected by any ifdef.

There are two code segments using the v2 API.  One was protected by `NO_NETCDF_2` ifdef, but that isn't defined in the CMake build.  Better to use the `NC_HAS_NC2` define which is in `netcdf_meta.h`

The second code segment was not protected by any ifdef.
I assumed netcdf.h included netcdf_meta.h, but now see that it doesn't and an explicit include is required.
@gsjaardema
Copy link
Contributor Author

NOTE: Another fix would be to add the NO_NETCDF_2 define to the CMakeLists.txt file in this directory and change the #if NC_HAS_NC2 to #ifndef NO_NETCDF_2. Not sure which is preferred, but in either case, the second block of code using the V2 API does need to be protected.

@edhartnett
Copy link
Contributor

config.h is the canonical location for information about what features of the build are turned on and off. It is already included in this test (as it must be) by nc_tests.h.

So I would strongly suggest that netcdf_meta.h not be included, and that the CMake build should be changed to also define NC_NETCDF_2, or else the configure.ac and config.h.in (and other C code) be changed to use NC_HAS_NC2 everywhere instead of NC_NETCDF_2.

But whatever is used, it should come from config.h.

@edhartnett
Copy link
Contributor

This PR should not be merged and can be taken down.

I have applied the V2 fix using config.h on my current branch, currently up as PR #755.

@edhartnett
Copy link
Contributor

@gsjaardema or @WardF can you please close this PR?

The fix for the V2 test code (using config.h) is part of the ejh_test_fills branch that I will be merging after the current PR backlog has been cleared. So this PR is no longer needed.

@gsjaardema gsjaardema closed this Jan 20, 2018
gsjaardema added a commit to gsjaardema/netcdf-c that referenced this pull request Jan 31, 2018
Remove test code that uses the version 2 API if the version 2 API code is not being activated in the build.

This was originally proposed in Unidata#656 with a better fix in Unidata#755 which was removed.
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.

3 participants