]> granicus.if.org Git - graphviz/commit
sfio: remove 'SF_ERROR'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 23 Oct 2022 02:44:19 +0000 (19:44 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 10 Nov 2022 02:59:49 +0000 (18:59 -0800)
commitead8c63c3606782ebd9901cb687d1f75098b8b5d
tree10d3b561d906f3aa7143dbe261c0418c545ba94b
parent6c956e8e58dcd7163494bb3a8219d67ffb3d8b40
sfio: remove 'SF_ERROR'

When doing some unrelated refactoring, Windows compile errors emerge:

  sfsetbuf.c
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\oaidl.h(322,9):
    error C2059: syntax error: 'constant'
    [C:\GitLab-Runner\builds\graphviz\graphviz\build\lib\sfio\sfio.vcxproj]

Some investigation leads us to a guess¹ that oaidl.h contains:

  typedef /* [v1_enum] */
  enum tagSF_TYPE
      {
          SF_ERROR    = VT_ERROR,
          SF_I1   = VT_I1,
          SF_I2   = VT_I2,
          SF_I4   = VT_I4,
          SF_I8   = VT_I8,
          SF_BSTR = VT_BSTR,
          SF_UNKNOWN  = VT_UNKNOWN,
          SF_DISPATCH = VT_DISPATCH,
          SF_VARIANT  = VT_VARIANT,
          SF_RECORD   = VT_RECORD,
          SF_HAVEIID  = ( VT_UNKNOWN | VT_RESERVED )
      }   SF_TYPE; // Line 319

673b9f1a7dbde9c9cc5d9a2a22ee835a08ab40ab tried to work around this in the past.
But there remained a foot gun. If you (possibly transitively) included sfio.h
but did not include sfhdr.h, you could end up facing this error.

Surprising as it may seem, nothing in the code base checks for `SF_ERROR`. So a
cleaner solution that removes the problem in perpetuity is to remove our
`SF_ERROR`. Note that `SF_FLAGS` does not need to be adjusted because `SF_ERROR`
was not a public flag.

Gitlab: fixes #2301

¹ https://stackoverflow.com/questions/13827599/oaidl-h319-error-c2057-expected-constant-expression
lib/sfio/sfexcept.c
lib/sfio/sfhdr.h
lib/sfio/sfio.h
lib/sfio/sfrd.c
lib/sfio/sfseek.c
lib/sfio/sfwr.c