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

GCC error when using unicodeobject.h #59198

Closed
ndparker mannequin opened this issue Jun 3, 2012 · 8 comments
Closed

GCC error when using unicodeobject.h #59198

ndparker mannequin opened this issue Jun 3, 2012 · 8 comments
Labels
build The build process and cross-build extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@ndparker
Copy link
Mannequin

ndparker mannequin commented Jun 3, 2012

BPO 14993
Nosy @loewis, @ndparker, @vstinner, @benjaminp, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2012-06-04.20:58:50.204>
created_at = <Date 2012-06-03.19:25:22.448>
labels = ['extension-modules', 'interpreter-core', 'build']
title = 'GCC error when using unicodeobject.h'
updated_at = <Date 2012-06-04.22:54:07.388>
user = 'https://github.com/ndparker'

bugs.python.org fields:

activity = <Date 2012-06-04.22:54:07.388>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2012-06-04.20:58:50.204>
closer = 'vstinner'
components = ['Extension Modules', 'Interpreter Core']
creation = <Date 2012-06-03.19:25:22.448>
creator = 'ndparker'
dependencies = []
files = []
hgrepos = []
issue_num = 14993
keywords = []
message_count = 8.0
messages = ['162229', '162245', '162252', '162253', '162291', '162292', '162298', '162302']
nosy_count = 6.0
nosy_names = ['loewis', 'ndparker', 'vstinner', 'benjamin.peterson', 'python-dev', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'compile error'
url = 'https://bugs.python.org/issue14993'
versions = ['Python 3.3']

@ndparker
Copy link
Mannequin Author

ndparker mannequin commented Jun 3, 2012

GCC error when using unicodeobject.h

This ist my first attempt to test an extension with python 3.3. I've been using the 3.3.0a4 tarball.

I'm using very strict compiler settings when compiling my extension modules, especially -Wall -Werror (along with a lot more flags, like -pedantic, -std=c89).

Including Python.h includes unicodeobject.h which emits:

/usr/include/python3.3/unicodeobject.h:905: error: type of bit-field 'overallocate' is a GCC extension
/usr/include/python3.3/unicodeobject.h:908: error: type of bit-field 'readonly' is a GCC extension

Maybe these should just be (unsigned) ints or something?

@ndparker ndparker mannequin added extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs) build The build process and cross-build labels Jun 3, 2012
@benjaminp
Copy link
Contributor

It might not matter if it's an extension that everyone implements.

@loewis
Copy link
Mannequin

loewis mannequin commented Jun 4, 2012

Compilation with gcc -std=c89 is not supported. Just drop this option. While Python strives to use C89, we will not distort to meet some abstract language compliance goal.

OTOH, I fail to see why they need to be bitfields: a plain unsigned char field should work as well (as would an int bitfield). Victor?

@ndparker
Copy link
Mannequin Author

ndparker mannequin commented Jun 4, 2012

I'm not talking about compiling python but my extension module. I *do* try supporting c89. Also relying on implementation extensions is bad style.

I think, there's a huge difference between public header files (standards are good) and linked C code (do whatever you like, although standards are good here as well). OTOH, is there a real difference between char:1 and int:1? That's what we're actually discussing here. If not, I suggest simply using int:1 and be done with it.

@python-dev
Copy link
Mannequin

python-dev mannequin commented Jun 4, 2012

New changeset 09736ae1c314 by Victor Stinner in branch 'default':
Issue bpo-14993: Use standard "unsigned char" instead of a unsigned char bitfield
http://hg.python.org/cpython/rev/09736ae1c314

@vstinner
Copy link
Member

vstinner commented Jun 4, 2012

OTOH, I fail to see why they need to be bitfields: a plain
unsigned char field should work as well (as would an int bitfield). Victor?

I chose a bitfield to have a more compact structure. I didn't know that a bitfield using unsigned char is a GCC extension: it compiles on Visual Studio 2008, isn't it?

The size of _PyUnicodeWriter doesn't really matter, so I replace the two fields with simple types.

@vstinner vstinner closed this as completed Jun 4, 2012
@loewis
Copy link
Mannequin

loewis mannequin commented Jun 4, 2012

I don't think the change had any effect on memory consumption: because of alignment, padding is inserted either way to fill the flags to four (32-bit) or eight bytes. So with the bit field, there were 7 bytes of padding on 64-bit systems, and now there are only 6 bytes of padding.

Yes, Visual C also supports the same extension. See the "Microsoft specific" section in

http://msdn.microsoft.com/en-us/library/yszfawxh(v=vs.80).aspx

@vstinner
Copy link
Member

vstinner commented Jun 4, 2012

I don't think the change had any effect on memory consumption: because of alignment, padding is inserted either way to fill the flags to four (32-bit) or eight bytes. So with the bit field, there were 7 bytes of padding on 64-bit systems, and now there are only 6 bytes of padding.

Oh, interesting information. I forgot the alignment thing.

Yes, Visual C also supports the same extension. See the "Microsoft specific" section in
http://msdn.microsoft.com/en-us/library/yszfawxh(v=vs.80).aspx

Oh, what is the "C" language nowadays?...

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

2 participants