Contributing Advent 4: MongoDB driver variable names
A while ago I started reading Expert C Programming, a book on the intricacies of C, written almost 20 years ago (in 1994). I can very greatly recommend this book, even for seasoned C developers. Even although I know about most of the subjects addressed in the book, I picked up a few new things as well.
Anyway, the book made me look at my default compiler flags again. I tended not to use -Wall at all, but I've since then expanded my CFLAGS to -Wall
-Wextra -Wdeclaration-after-statement -Wmissing-field-initializers
-Wshadow -Wno-unused-parameter. When running with the new flags, the MongoDB driver for PHP started throwing (among others) the following warning during compilation:
/home/derick/dev/php/derickr-mongo-php-driver/bson.c:1069:12: warning: declaration of ‘buffer’ shadows a global declaration [-Wshadow]
char *buffer;
^
At first I found this odd, as I could not find the declaration at all, until I looked closer at the location where the compiler though I had the error:
In file included from /home/derick/dev/php/derickr-mongo-php-driver/bson.c:26:0: /home/derick/dev/php/derickr-mongo-php-driver/php_mongo.h:301:3: warning: shadowed declaration is here [-Wshadow] } buffer; ^
And this pointed me to the buffer struct:
typedef struct {
char *start;
char *pos;
char *end;
} buffer;
This typedef declares buffer into the global scope and therefore the compiler rightfully warns us about this when trying to compile char
*buffer; in a function. The fix was to add the prefix mongo_ so that the new name becomes mongo_buffer. The mongo_ prefix is what we use for all the other structs we define as well.
Life Line
This is indeed no more a clothes shop, but a restaurant
Created 2 waste_baskets, 2 boards, and 2 benches; Updated 8 benches, 6 waste_baskets, and 2 other objects; Deleted 2 waste_baskets and a bench
Updated a pub
Merge branch 'v2022'
Merge branch 'php_gh_19803' into v2022
Fix PHP GH-19803: Parsing a string with a single white space does cre…
Merge branch 'xdebug_3_5'
Back to -dev
Go with 3.5.1
Thanks Brussels, you've been lovely to me this weekend.
And I've a lot to process from the conference too.
I walked 3.9km in 36m24s
I walked 1.1km in 11m31s
Updated a restaurant; Confirmed 3 fast_foods, a convenience shop, and 2 other objects
I walked 4.4km in 44m06s
I walked 5.1km in 56m16s
I walked 3.8km in 37m43s
I'm up early to get the Eurostar to #FOSDEM and I've already seen friends being made.
Fixed another address
Fixed address for flats
Fixed address, and ass missing service way
I walked 6.4km in 1h20m58s
I walked 11.4km in 9m22s
I walked 10.4km in 1h41m18s
I walked 7.4km in 1h26m49s
Good job antivaxer shit heads:
BBC News: UK loses measles elimination status


Shortlink
This article has a short URL available: https://drck.me/adv1304-aet