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

Fix compiler error for Visual Studio 2013+ in ntextapi.h #936

Merged
merged 1 commit into from Nov 11, 2016

Conversation

maxbelanger
Copy link
Contributor

In winternl.h, the following enumeration conflicts with the one defined in ntextapi.h:

typedef enum _PROCESSINFOCLASS {
    ProcessBasicInformation = 0,
    ProcessDebugPort = 7,
    ProcessWow64Information = 26,
    ProcessImageFileName = 27,
    ProcessBreakOnTermination = 29
} PROCESSINFOCLASS;

The current fix for this that uses an _MSC_VER check (for issue #688 ) but that doesn't fully resolve the issue, as this can happen on Visual Studio 2013 (aka 1800) when using the Windows 8.1 SDK, as I've experienced:

c:\users\max\src\psutil\psutil\arch\windows\ntextapi.h(324) : error C2365: 'ProcessBreakOnTermination' : redefinition; previous definition was 'enumerator'
        C:\Program Files (x86)\Windows Kits\8.1\include\um\winternl.h(308) : see declaration of 'ProcessBreakOnTermination'
c:\users\max\src\psutil\psutil\arch\windows\ntextapi.h(324) : error C2086: '_PROCESSINFOCLASS2 ProcessBreakOnTermination' : redefinition
        c:\users\max\src\psutil\psutil\arch\windows\ntextapi.h(324) : see declaration of 'ProcessBreakOnTermination'

The typical way collisions with this enum are resolved is through underscore-prefixed surrogates (see _ProcessImageFileName). This patch uses the same technique for the ProcessBreakOnTermination item, which should end up with the same value (29). This fixes the build on my machine.

I'm not fully aware of the context surrounding the original issue, so apologies if this doesn't actually solve anything or if I'm missing something obvious :).

@giampaolo giampaolo merged commit 875dd3e into giampaolo:master Nov 11, 2016
giampaolo added a commit that referenced this pull request Nov 11, 2016
@giampaolo
Copy link
Owner

Merged, thanks.

nlevitt added a commit to nlevitt/psutil that referenced this pull request Apr 9, 2019
* master: (375 commits)
  update psutil
  fix procsmem script which was not printing processes
  try to fix tests on travis
  try to fix tests on travis
  OSX: fix compilation warning
  giampaolo#936: give credits to Max Bélanger
  giampaolo#811: move DLL check logic in _pswindows.py
  winmake: use the right win slashes
  winmake: do not try to install GIT commit hook if this is not a GIT cloned dir
  giampaolo#811: on Win XP let the possibility to install psutil from sources as it still (kind of) works)
  giampaolo#811: add a Q&A section in the doc; tell what Win versions are supported
  giampaolo#811: raise a meaningful error message if on Windows XP
  update doc; bump up version
  giampaolo#939: update MANIFEST to include only src files and not much else
  update HISTORY
  travis: execute mem leaks and flake8 tests only on py 2.7 and 3.5; no need to test all python versions
  bump up version
  update version in doc
  add simple test case for oneshot() ctx manager
  add simple test case for oneshot() ctx manager
  speedup fetch all process test by using oneshot
  giampaolo#799 - oneshot / linux: speedup memory_full_info and memory_maps
  fix flake8
  first pass
  giampaolo#943: better error message in case of version conflict on import.
  update doc
  799 onshot / win: no longer store the handle in python; I am now sure this is slower than using OpenProcess/CloseHandle in C
  update doc
  (win) add memleak test for proc_info()
  move stuff around
  memleak: fix false positive on windows
  giampaolo#933 (win) fix memory leak in WindowsService.description()
  giampaolo#933 (win) fix memory leak in cpu_stats() (missing free())
  refactoring
  giampaolo#799 / win: pass handle also to memory_maps() and username() functions
  fix numbers
  mem leak script: provide better error output in case of failure
  refactor memleak script
  refactor memleak script
  refactor memleak script
  refactor memleak script
  refactor memleak script: get rid of no longer used logic to deal with Process properties
  memleak script refactoring
  doc styling
  giampaolo#799 / win: use oneshot() around num_threads() and num_ctx_switches(); speedup from 1.2x to 1.8x
  refactor windows tests
  win: enable dueal process impl tests
  win / C: refactor memory_info_2 code() and return it along side other proc_info() metrics
  windows c refactor proc_info() code
  update windmake script
  winmake clean: make it an order of magnitude faster; also update Makefile
  update doc
  bench script: add psutil ver
  winmake: more aggressive logic to uninstall psutil
  adjust bench2 script to new perf API
  try to adjust perf
  upgrade perf code
  memory leak script: humanize memory difference in case of failure
  style changes
  fix giampaolo#932 / netbsd: check connections return value and raise exception
  netbsd / connections: refactoring
  netbsd / connections: refactoring
  netbsd / connections: refactoring
  netbsd / connections: refactoring
  netbsd / connections: refactoring
  testing make clean with unittests was a bad idea after all
  make 'make clean' 4x faster!
  add test for make clean
  adjust winmake script
  fix netbsd/openvsd compilation failure
  bsd: fix mem leak
  osx: fix memory leak
  pre-release
  refactoring
  update IDEAS
  add mtu test for osx and bsd
  osx: separate IFFLAGS function
  osx/bsd: separate IFFLAGS function
  linux: separate IFFLAGS function
  share C function to retrieve MTU across all UNIXes
  HISTORY: make anchors more easily referenceable
  fix giampaolo#927: Popen.__del__ may cause maximum recursion depth error.
  fix Popen test which is occasionally failing
  more releases timeline from README to doc
  ignore failing tests on OSX + TRAVIS
  update INSTALL instructions
  update print_announce.py script
  update HISTORY
  HISTORY: provide links to issues on the bug tracker
  update IDEAS
  giampaolo#910: [OSX / BSD] in case of error, psutil.pids() raised RuntimeError instead of the original OSError exception.
  fix unicode tests on windows / py3
  small test refactoring
  fix giampaolo#926: [OSX] Process.environ() on Python 3 can crash interpreter if process environ has an invalid unicode string.
  osx: fix compiler warnings
  refactor unicode tests
  fix unicode test
  giampaolo#783: fix some unicode related test failures on osx
  test refactoring
  test refactroring
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants