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

Avoid redefinition of strcasecmp under mingw-w64 #2106

Merged
merged 8 commits into from
Jan 13, 2022

Conversation

mjwoods
Copy link
Contributor

@mjwoods mjwoods commented Sep 4, 2021

Fixes #2083

NetCDF defines strcasecmp as a preprocessor macro on Windows platforms. This is probably needed for the Microsoft compilers, but the header files used by mingw-w64 compilers define strcasecmp as an inline function.

If both the inline function and the macro definitions are used with gcc at high optimisation levels (specifically the flag -foptimize-sibling-calls, which is included by default at -O2 or higher), the OpenDAP tests hang.

On mingw-w64, the macro __MINGW32__ is defined in both 32-bit and 64-bit environments. If this macro is defined, the macro definition of strcasecmp can be disabled, which avoids the hang when running OpenDAP tests.

@DennisHeimbigner
Copy link
Collaborator

This should be changed in netcdf-c/include/ncconfigure.h
which already has a number of such tests, including one for strcasecmp.

@mjwoods
Copy link
Contributor Author

mjwoods commented Sep 5, 2021

Hi @DennisHeimbigner , I have attempted to implement the definitions of strcasecmp (and related functions) in ncconfigure.h, removing similar definitions from other files. Is that what you had in mind?

@DennisHeimbigner
Copy link
Collaborator

Hah! did not realize is was so ubiquitous.
Yes, centralizing into ncconfigure.h is what I meant.
There are, however some exceptions for code that is intended
to be "standalone" and independent of the netcdf library for a
a variety of reasons. These include the following:

  1. libdispatch/nclists.c
  2. libdispatch/ncjson.c
  3. libdispatch/ncuri.c

So those probably should have your fix; in all other cases, adding config.h (if not already
there) is the right thing to do.

@mjwoods
Copy link
Contributor Author

mjwoods commented Sep 6, 2021

I have removed config.h from nclists.c and ncjson.c , restoring my earlier fix for mingw.

I have not changed ncuri.c at all yet, but it does include config.h .

@WardF WardF merged commit 20187ce into Unidata:main Jan 13, 2022
@mjwoods mjwoods deleted the mingw-w64-strcasecmp branch April 13, 2022 09:59
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.

OpenDAP hang on Mingw-w64
3 participants