allow benign typedef redefinitions (C11)
Peter Eisentraut <peter@eisentraut.org>
Attachments
- 0001-Improve-pgbench-definition-of-yyscan_t.patch (text/plain) patch 0001
- 0002-Allow-redeclaration-of-typedef-yyscan_t.patch (text/plain) patch 0002
- 0003-Remove-workarounds-against-repeat-typedefs.patch (text/plain) patch 0003
- 0004-Improve-ExplainState-type-handling-in-header-files.patch (text/plain) patch 0004
- 0005-Update-various-forward-declarations-to-use-typedef.patch (text/plain) patch 0005
- 0006-Remove-hbaPort-type.patch (text/plain) patch 0006
- 0007-Change-fmgr.h-typedefs-to-use-original-names.patch (text/plain) patch 0007
Here is the first of several (to come at a later date) patch sets to take some advantage of C11 features. This is, I hope, a very gentle start that shouldn't stress even older compilers very much, and should bring some tangible benefits that had already been asked for around here. In C11, typedef redefinitions are allowed, as long as they are the same. So typedef int foo; typedef int foo; is allowed, where the second occurrence would have led to a diagnostic in previous C versions. (C++ also allows this, so this will preserve C++ compatibility of the headers.) What is not allowed is something like this of course: typedef int foo; typedef double foo; This will continue to be an error. This facility is often useful to untangle dependencies between header files. So instead of having one header include another, now the first header can just make its own typedef of whatever types it needs. If the two headers are later included together, then this will not (any more) be a conflict. This often works together with declaring incomplete types using struct. The PostgreSQL code already contains a couple of places that wanted to do something like this but had to install manual workarounds with #ifdef guards. These can now be removed. There are also a bunch of struct forward declarations that can be "upgraded" to full typedefs. This makes the function prototypes look more consistent. In this patch set, 0001 is a prerequisite for 0002, 0002 and 0003 remove some existing workarounds, the remaining patches are additional opportunities for cleanup and simplification. All of this is only notational, there are no include changes or API changes or changes in behavior. (After this, it would probably be possible to undertake some deeper efforts to untangle header files, with the help of IWYU. But that is a separate project.)
Commits
-
Move instrumentation-related structs to instrument_node.h
- 2defd0006255 19 (unreleased) landed
-
Don't include access/htup_details.h in executor/tuptable.h
- 1a8b5b11e48a 19 (unreleased) landed
-
Don't include execnodes.h in brin.h or gin.h
- 1b6f61bd8988 19 (unreleased) landed
-
Do a tiny bit of header file maintenance
- 3bf31dd24314 19 (unreleased) landed
-
Don't include execnodes.h in replication/conflict.h
- 7e638d7f5093 19 (unreleased) landed
- 47da1745244b 18.1 landed
-
Update some more forward declarations to use typedef
- 81fc3e28e383 19 (unreleased) landed
-
Change fmgr.h typedefs to use original names
- 4bd91912987d 19 (unreleased) landed
-
Improve ExplainState type handling in header files
- 70407d39b7ea 19 (unreleased) landed
-
Remove hbaPort type
- dc41d7415fc6 19 (unreleased) landed
-
Remove workarounds against repeat typedefs
- 1e3b5edb8eb2 19 (unreleased) landed
-
Update various forward declarations to use typedef
- d4d1fc527bdb 19 (unreleased) landed
-
Allow redeclaration of typedef yyscan_t
- ae0e1be9f2a2 19 (unreleased) landed
-
Improve pgbench definition of yyscan_t
- 675ddc4d704f 19 (unreleased) landed
-
Delay extraction of TIDBitmap per page offsets
- bfe56cdf9a4e 18.0 cited
-
Remove pgrminclude and associated scripts
- 5af699066f81 18.0 cited
-
Allow to use HeapTupleData embedded in [Buffer]HeapTupleTableSlot.
- 5408e233f066 12.0 cited