Use the MSVC pipe function spellings in pio.c - #506
Open
lenzo-ka wants to merge 1 commit into
Open
Conversation
The Win32 C runtime exports the pipe functions as _popen and _pclose. The POSIX spellings are declared in <stdio.h>, so HAVE_POPEN is set and the code compiles, but they are not resolvable when linking a shared library; an MSVC DLL build of the pocketsphinx library therefore fails with LNK2019 on popen. fclose_comp already used _pclose under _WIN32, but fopen_comp still called bare popen, so the two sides disagreed. Map popen and pclose to the underscore spellings on Win32 in one place, and drop the now-redundant inline _pclose guard, so both pipe calls use the spelling the CRT exports. The guard is inert off Win32, leaving behavior on other platforms unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Microsoft C runtime exports the pipe functions as
_popen/_pclose.pio.calready used_pcloseon the close side under_WIN32, butfopen_comp()called barepopen(), so an MSVC shared-library build failed to link:This maps
popen/pcloseto the underscore spellings on Win32 in one place and drops the now-redundant inline_pcloseguard, so both pipe calls use the spelling the CRT exports. The guard is inert off Win32; behavior on other platforms is unchanged.Verified by linking the pipe construct as a DLL under MSVC: it fails with
LNK2019before the change and links cleanly after. A non-Windows build is unaffected — the preprocessed translation unit is identical to before the change off_WIN32.Fixes #505