The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Thursday, January 25, 2001

BSD headers—Just Say No!

I got called to help a friend compile a program. He's still learning C and the program he was compiling was throwing up the following error:

gcc  -O2 -DHAVE_CONFIG_H -D_GNU_SOURCE   -I. -Iprotos -c action.c
action.c: In function `action_command':
action.c:51: void value not ignored as it ought to be
action.c: In function `substitute_vars':
action.c:138: void value not ignored as it ought to be
action.c:143: void value not ignored as it ought to be
action.c:163: void value not ignored as it ought to be
action.c: In function `check_one_action':
action.c:245: void value not ignored as it ought to be
make: *** [action.o] Error 1

It was failing on the strcpy() and strncpy() functions. It was apparent to me that the program was using an improper definition of the functions—the problem was to figure out where it was pulling the defintions in from. Easy enough to generate what the preprocessor was feeding into the compiler (with gcc using the -E option and sending the output to a file).

The original lines:

if (*!ptr)
  strcpy(pr, "5"); /* defaults priority to 5 if no value given */

And the preprocessor was spitting out:

  if(!*pr)
    (__extension__ (__builtin_constant_p (  "5" )       ? (((size_t)(const
void *)((   "5"  ) + 1) - (size_t)(const void *)(   "5"  ) == 1)  && strlen
(  "5" ) + 1 <= 8        ? __strcpy_small ( pr , __extension__ (((__const  
unsigned char *) (__const char *) (    "5"   ))[  0  + 1] << 8 | ((__const 
unsigned char *) (__const char *) (    "5"   ))[  0 ]) ,    __extension__  
(((__const unsigned char *) (__const char *) (    "5"   ))[  4  + 1] << 8 |
((__const unsigned char *) (__const char *) (    "5"   ))[  4 ]) ,
__extension__ (((((__const unsigned char *) (__const char *) (    "5"   ))[
0  + 3] << 8 | ((__const unsigned char *) (__const char *) (    "5"   ))[  0
+ 2]) << 8 | ((__const unsigned char *) (__const char *) (    "5"   ))[  0  
+ 1]) << 8 | ((__const unsigned char *) (__const char *) (    "5"   ))[  0  
]) ,  __extension__ (((((__const unsigned char *) (__const char *) (    "5" 
))[  4  + 3] << 8 | ((__const unsigned char *) (__const char *) (    "5"    
))[  4  + 2]) << 8 | ((__const unsigned char *) (__const char *) (    "5"   
))[  4  + 1]) << 8 | ((__const unsigned char *) (__const char *) (    "5"   
))[  4 ])  , strlen (  "5" ) + 1)    : (char *) bcopy(    "5"  ,   pr  ,    
strlen (  "5" ) + 1 ) )   : strcpy ( pr ,   "5" ))) ;

Oh my. Mind you, that was one line and no attempt to even comprehend that is being made (in fact, the breaks are just where hey happened when I copied the text in).

Checking the file futher, I can see it's including strings.h which is not part of the ANSI standard. In fact, it's an old BSDism, which shouldn't be used anymore. Some mucking about with the header file spit out by configure got the compile to work.

So much for using configure.

Obligatory Picture

[The future's so bright, I gotta wear shades]

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

https://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.