[New-bugs-announce] [issue42078] _tracemalloc.c and Clang-cl

Gisle Vanem report at bugs.python.org
Mon Oct 19 03:03:42 EDT 2020


New submission from Gisle Vanem <gvanem at yahoo.no>:

Related to:
  https://bugs.python.org/issue33351

where I commented above the following. 
When using `clang-cl` to build, I get the following error:
```
Modules/_tracemalloc.c(55,9): error: declaration of anonymous struct must be a definition
typedef struct
        ^
Modules/_tracemalloc.c(55,1): warning: typedef requires a name [-Wmissing-declarations]
typedef struct
^~~~~~~
Modules/_tracemalloc.c(68,9): warning: #pragma pack(pop, ...) failed: stack empty [-Wignored-pragmas]
#pragma pack(pop)
        ^
Modules/_tracemalloc.c(78,5): error: unknown type name 'frame_t'
    frame_t frames[1];
    ^
Modules/_tracemalloc.c(87,103): error: use of undeclared identifier 'frame_t'
static const unsigned long MAX_NFRAME = Py_MIN(UINT16_MAX, ((SIZE_MAX - sizeof(traceback_t)) / sizeof(frame_t) + 1));
                                                                                                      ^
Modules/_tracemalloc.c(87,103): error: use of undeclared identifier 'frame_t'
Modules/_tracemalloc.c(286,15): error: unknown type name 'frame_t'; did you mean 'trace_t'?
        const frame_t *frame1 = &traceback1->frames[i];
              ^~~~~~~
              trace_t
Modules/_tracemalloc.c(100,3): note: 'trace_t' declared here
} trace_t;
  ^
```

An easy fix is to patch it:
```
--- a/_tracemalloc.c 2020-10-18 12:06:55
+++ b/_tracemalloc.c 2020-10-19 09:02:17
@@ -52,11 +52,11 @@

 /* Pack the frame_t structure to reduce the memory footprint on 64-bit
    architectures: 12 bytes instead of 16. */
-typedef struct
 #ifdef __GNUC__
-__attribute__((packed))
+typedef struct __attribute__((packed))
 #elif defined(_MSC_VER)
 #pragma pack(push, 4)
+typedef struct
 #endif
 {
     /* filename cannot be NULL: "<unknown>" is used if the Python frame
```

(I'm amazed it's not done before).

----------
components: Build
messages: 378928
nosy: gvanem
priority: normal
severity: normal
status: open
title: _tracemalloc.c and Clang-cl
type: compile error
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42078>
_______________________________________


More information about the New-bugs-announce mailing list