So you’ve downloaded PG+ from the website, unpacked it, typed make followed by make install and watched as your screen filled with compile errors.

So todays task is to get PG+ to compile without any warnings.

Now compiling .... admin2.c 0 adm lines
In file included from admin2.c:24:0:
include/proto.h:235:13: warning: conflicting types for built-in function log

Back when PG+ was first written, math functions were contained in their own header file, todays compilers however are aware of them, hence the warning message. Its not really a problem as we’re not linking with the math library so the PG+ log function is the one that will be used. We’ll solve this warning by renaming PG+’s function logF (which makes sense as theres a companion PG+ function called LOGF).

On a 64bit operating the next error we encounter looks like this.

Now compiling .... aliases.c alia lines
aliases.c: In function tmp_comp_alias:
aliases.c:77:24: warning: cast from pointer to integer of different size
aliases.c:77:38: warning: cast from pointer to integer of different size

Looking at the line immediately reveals the problem:

store_int(oldstack, ((int) stack - (int) oldstack));

An 8 byte pointer is being assigned to a 4 byte integer. We can easily fix that warning by removing the forced casts and allowing the compiler to do the necessary type conversions. The rest of those errors all have the same underlying cause, if not the same solution.

Now compiling .... glue.c 3 glu lines
glue.c: In function main:
glue.c:1778:7: warning: format %d expects type int, but argument 3 has type long int

And the offending line looks like:
sprintf(stack_start, "Lost stack reclaimed %d bytes\n", stack - stack_start);
We can fix this one by either changing the format specifier to handle a long int, or casting the the pointer math to an int, both are valid fixes in this instance.

intercom_glue.c: In function start_intercom:
intercom_glue.c:138:7: warning: missing sentinel in function call

Which is usually caused by a variable number of arguments not being terminated by a NULL value, heres the line in question.
execlp ("bin/intercom", intercom_name, 0);
And heres the fix.
execlp ("bin/intercom", intercom_name, (char *)NULL);

And the last 2 errors from that file.
intercom_glue.c:152:3: warning: implicit declaration of function time
intercom_glue.c:152:3: warning: nested extern declaration of time

Time functions are spread across time.h and sys/time.h, so its just a matter of ensuring both are included.

items.c:969:32: warning: trigraph ??! ignored, use -trigraphs to enable

And for that one we just need to edit the text to ensure the preprocessor isn’t confused.

And after all that work, we’re finally ready to boot our talker.

Advertisements