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

Bullseye build broken #129

Closed
adr26 opened this issue Jun 14, 2021 · 8 comments
Closed

Bullseye build broken #129

adr26 opened this issue Jun 14, 2021 · 8 comments

Comments

@adr26
Copy link

adr26 commented Jun 14, 2021

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
adr26 pushed a commit to adr26/bitarray that referenced this issue Jun 14, 2021
ilanschnell added a commit that referenced this issue Jun 15, 2021
Fix build with MSVC / Bullseye, #129
@ilanschnell
Copy link
Owner

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

@adr26
Copy link
Author

adr26 commented Jun 15, 2021

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

@adr26 adr26 closed this as completed Jun 15, 2021
@ilanschnell
Copy link
Owner

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

@ilanschnell
Copy link
Owner

ilanschnell commented Jul 5, 2021

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
Copy link
Author

adr26 commented Jul 5, 2021

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

@adr26 adr26 reopened this Jul 5, 2021
@ilanschnell
Copy link
Owner

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
Copy link
Author

adr26 commented Jul 5, 2021

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.

@adr26 adr26 closed this as completed Jul 5, 2021
@ilanschnell
Copy link
Owner

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

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

No branches or pull requests

2 participants