benghancock

benghancock

Munging data and raking the muck, mostly with Python. This is my personal account.

Member Since 5 years ago

San Francisco Bay Area

Experience Points
5
follower
Lessons Completed
11
follow
Lessons Completed
43
stars
Best Reply Awards
9
repos

120 contributions in the last year

Pinned
⚡ rapidly search judicial calendars
⚡ Visualizing COVID-19 hospitalization data in California
⚡ Manual and automated processes of sourcing data for the stop-covid19-sfbayarea project
⚡ An Open sqlite Database on SF Bay Area COVID-19 Metrics
Activity
Dec
27
3 weeks ago
Activity icon
issue

benghancock issue comment 9fans/plan9port

benghancock
benghancock

Compiler throws a warning for u.h sizeof

/home/sn0w/plan9port/include/u.h:65:42: warning: expression does not compute the number of elements in this array; element type is ‘struct __jmp_buf_tag’, not ‘long int’ [-Wsizeof-array-div] 65 | typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; | ^ /home/sn0w/plan9port/include/u.h:65:42: note: add parentheses around the second ‘sizeof’ to silence this warning

benghancock
benghancock

I ran into the same issue, so figured I'd chime in on this thread even though it's been open for a while. First things first though: Thanks very much for plan9port! I came to know the joys of using Acme thanks to this project.

I ran the INSTALL script on a machine running openSUSE the other day and saw a stream of repeated compiler warnings, the most common of which was this one, excerpted with context:

>>> cd /usr/local/plan9/src/cmd/devdraw; mk -k install
9c -I/usr/include x11-load.c
/usr/local/plan9/include/u.h:65:42: warning: expression does not compute the number of elements in this array; element type is ‘struct __jmp_buf_tag’, not ‘long int’ [-Wsizeof-array-div]
   65 | typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
      |                                          ^
/usr/local/plan9/include/u.h:65:42: note: add parentheses around the second ‘sizeof’ to silence this warning

My knowledge of C is very shallow, but following the message in the warning, I tried making this change (which I see is already a PR in #520)

diff --git a/include/u.h b/include/u.h
index 856e10f4..3d779483 100644
--- a/include/u.h
+++ b/include/u.h
@@ -62,7 +62,7 @@ extern "C" {
 #define _NEEDUINT 1
 #define _NEEDULONG 1

-typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
+typedef long p9jmp_buf[sizeof(sigjmp_buf)/(sizeof(long))];

 #if defined(__linux__)
 #      include <sys/types.h>

Re-executing ./INSTALL afterward successfully silences this warning, and things still seem to work fine (though I admittedly only tested Acme).

Here's the version of gcc I was running:

gcc version 11.2.1 20211124 [revision 7510c23c1ec53aa4a62705f0384079661342ff7b] (SUSE Linux)

OS information

$ lsb_release -a
LSB Version:    n/a
Distributor ID: openSUSE
Description:    openSUSE Tumbleweed
Release:        20211223
Codename:       n/a

Acme also worked without the change, and I'm not sure if the change would have other effects elsewhere, but I thought I would share this info in case it's helpful.

Thanks again!

Oct
19
3 months ago