ilanschnell/bitarray

Bullseye build broken

Closed this issue · 8 comments

adr26 commented

When compiling on Windows with Bullseye Coverage, the build is broken because of C89 compatibility issues:

C:\Temp\bitarray>python setup.py install
running install
running build
running build_py
running build_ext
building 'bitarray._bitarray' extension
C:\Program Files (x86)\BullseyeCoverage\bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tcbitarray/_bitarray.c /Fobuild\temp.win32-2.7\Release\bitarray/_bitarray.obj
_bitarray.c
c:\temp\bitarray\bitarray\pythoncapi_compat.h(264) : error C2143: syntax error : missing ';' before 'type'
c:\temp\bitarray\bitarray\pythoncapi_compat.h(265) : error C2065: 'res' : undeclared identifier
c:\temp\bitarray\bitarray\pythoncapi_compat.h(268) : error C2065: 'res' : undeclared identifier
c:\temp\bitarray\bitarray\bitarray.h(64) : error C2054: expected '(' to follow 'inline'
c:\temp\bitarray\bitarray\bitarray.h(65) : error C2085: 'setbit' : not in formal parameter list
c:\temp\bitarray\bitarray\bitarray.h(65) : error C2143: syntax error : missing ';' before '{'
c:\temp\bitarray\bitarray\bitarray.h(80) : error C2054: expected '(' to follow 'inline'
c:\temp\bitarray\bitarray\bitarray.h(81) : error C2085: 'setunused' : not in formal parameter list
c:\temp\bitarray\bitarray\bitarray.h(81) : error C2143: syntax error : missing ';' before '{'
c:\temp\bitarray\bitarray\bitarray.h(114) : error C2054: expected '(' to follow 'inline'
c:\temp\bitarray\bitarray\bitarray.h(115) : error C2085: 'pybit_as_int' : not in formal parameter list
c:\temp\bitarray\bitarray\bitarray.h(115) : error C2143: syntax error : missing ';' before '{'
bitarray/_bitarray.c(191) : warning C4013: 'setunused' undefined; assuming extern returning int
bitarray/_bitarray.c(236) : warning C4013: 'setbit' undefined; assuming extern returning int
bitarray/_bitarray.c(439) : warning C4013: 'pybit_as_int' undefined; assuming extern returning int
error: command 'C:\\Program Files (x86)\\BullseyeCoverage\\bin\\cl.exe' failed with exit status 2

Thanks for finding this problem and fixing it. I've merged PR #130, and will make a 2.1.3 release very soon.

adr26 commented

Thank you for accepting my fix. python/pythoncapi-compat#11 has been accepted and merged as well, so I'm 2/2 from yesterday!

I just released bitarray 2.1.3 which contains this fix. Thanks again!

As your fix is now included in pythoncapi_compat.h, and because now pythoncapi_compat.h is always included before bitarray.h, I've removed the original fix again: dbd5874

adr26 commented

As your fix is now included in pythoncapi_compat.h, and because now pythoncapi_compat.h is always included before bitarray.h, I've removed the original fix again: dbd5874

Unfortunately, this doesn't work as the macros are undefined at the end of pythoncapi_compat.h:

#ifdef PYTHONCAPI_COMPAT_MSC_INLINE
#  undef inline
#  undef PYTHONCAPI_COMPAT_MSC_INLINE
#endif

So the build of the latest code from github fails:

C:\WDLABS\bitarray>git log -1
commit dbd5874347e4780acb3a2af2f029f1a79325244a (HEAD -> master, origin/master, origin/HEAD)
Author: Ilan Schnell <ilanschnell@gmail.com>
Date:   Sun Jul 4 22:51:38 2021 -0500

    remove duplicate definition of inline, this is already handled in pythoncapi_compat.h, which we always include before bitarray.h

C:\WDLABS\bitarray>python setup.py install
running install
running build
running build_py
running build_ext
building 'bitarray._bitarray' extension
C:\Program Files (x86)\BullseyeCoverage\bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tcbitarray/_bitarray.c /Fobuild\temp.win32-2.7\Release\bitarray/_bitarray.obj
_bitarray.c
c:\wdlabs\bitarray\bitarray\bitarray.h(64) : error C2054: expected '(' to follow 'inline'
c:\wdlabs\bitarray\bitarray\bitarray.h(65) : error C2085: 'setbit' : not in formal parameter list
c:\wdlabs\bitarray\bitarray\bitarray.h(65) : error C2143: syntax error : missing ';' before '{'
c:\wdlabs\bitarray\bitarray\bitarray.h(80) : error C2054: expected '(' to follow 'inline'
c:\wdlabs\bitarray\bitarray\bitarray.h(81) : error C2085: 'setunused' : not in formal parameter list
c:\wdlabs\bitarray\bitarray\bitarray.h(81) : error C2143: syntax error : missing ';' before '{'
c:\wdlabs\bitarray\bitarray\bitarray.h(114) : error C2054: expected '(' to follow 'inline'
c:\wdlabs\bitarray\bitarray\bitarray.h(115) : error C2085: 'pybit_as_int' : not in formal parameter list
c:\wdlabs\bitarray\bitarray\bitarray.h(115) : error C2143: syntax error : missing ';' before '{'
bitarray/_bitarray.c(188) : warning C4013: 'setunused' undefined; assuming extern returning int
bitarray/_bitarray.c(233) : warning C4013: 'setbit' undefined; assuming extern returning int
bitarray/_bitarray.c(436) : warning C4013: 'pybit_as_int' undefined; assuming extern returning int
error: command 'C:\\Program Files (x86)\\BullseyeCoverage\\bin\\cl.exe' failed with exit status 2

Could you either reinstate the original fix, or copy the workaround from pythoncapi_compat.h?

// Compatibility with Visual Studio 2013 and older which don't support
// the inline keyword in C (only in C++): use __inline instead.
#if (defined(_MSC_VER) && _MSC_VER < 1900 \
     && !defined(__cplusplus) && !defined(inline))
#  define inline __inline
#  define PYTHONCAPI_COMPAT_MSC_INLINE
   // These two macros are undefined at the end of this file
#endif

Thanks, Andrew R

Ah, thanks. I overlooked the comment that inline is undefined at the end of pythoncapi_compat.h. I pushed the fix: 0b5bceb

Do you know why this definition is undefined at the end of pythoncapi_compat.h? I think it would make sense to keep the workaround present.

adr26 commented

Thanks - I confirmed the build fix worked.

I assume the macros were undefined at the end of pythoncapi_compat.h out of an abundance of caution, and so that they don't interfere with any code that a user of pythoncapi_compat.h may include it in (since it is intended to be a general-purpose utility header).

In your case it would not be expected that any other code #includes bitarray.h and so not #undef-ing the macros at the bottom of bitarray.h is acceptable.

Thanks for confirming that the build is working again. Yes, I also think #undef-ing is not necessary in my case.