This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH dllwrap.c: Build error with GCC 3.5: static mismatch


Hi Aaron,

GCC gives an error about program_name in dllwrap.c conflicting with a
non-static version in bucomm.h.  The following patch corrects this by
not making the global variable static.

Actually this is not entirely correct since a) the variable is supposed to be static - it is not used outside of dllwrap.c, b) the variable referred to in bucomm.h is actually defined in bucomm.c. A better fix in my opinion is to rename the variable so as to avoid the name conflict. In doing this I also came across another, related problem: dllwrap.c:deduce_name() has a parameter called 'program_name' which shadows the global variable.


So I have applied a patch to fix both of these issues.

binutils/ChangeLog
2004-07-13  Nick Clifton  <nickc@redhat.com>

	* dllwrap.c: Replace 'program_name' with 'prog_name' to avoid
	conflicts with exported global defined in bucomm.h.
	(deduce_name): Rename parameter 'program_name' to 'name' to avoid
	shadowing the global defined in bucomm.h.

Cheers
  Nick

Index: dllwrap.c
===================================================================
RCS file: /cvs/src/src/binutils/dllwrap.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -c -3 -p -r1.13 -r1.14
*** dllwrap.c	14 Sep 2003 12:20:16 -0000	1.13
--- dllwrap.c	13 Jul 2004 16:46:51 -0000	1.14
*************** static target_type which_target = UNKNOW
*** 101,107 ****
  static int dontdeltemps = 0;
  static int dry_run = 0;
  
! static char *program_name;
  
  static int verbose = 0;
  
--- 101,107 ----
  static int dontdeltemps = 0;
  static int dry_run = 0;
  
! static char *prog_name;
  
  static int verbose = 0;
  
*************** static void cleanup_and_exit (int);
*** 139,146 ****
  static void
  display (const char * message, va_list args)
  {
!   if (program_name != NULL)
!     fprintf (stderr, "%s: ", program_name);
  
    vfprintf (stderr, message, args);
    fputc ('\n', stderr);
--- 139,146 ----
  static void
  display (const char * message, va_list args)
  {
!   if (prog_name != NULL)
!     fprintf (stderr, "%s: ", prog_name);
  
    vfprintf (stderr, message, args);
    fputc ('\n', stderr);
*************** look_for_prog (const char *prog_name, co
*** 244,260 ****
     Returns a dynamically allocated string.  */
  
  static char *
! deduce_name (const char *prog_name)
  {
    char *cmd;
!   char *dash, *slash, *cp;
  
    dash = NULL;
    slash = NULL;
!   for (cp = program_name; *cp != '\0'; ++cp)
      {
        if (*cp == '-')
  	dash = cp;
        if (
  #if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__)
  	  *cp == ':' || *cp == '\\' ||
--- 244,263 ----
     Returns a dynamically allocated string.  */
  
  static char *
! deduce_name (const char * name)
  {
    char *cmd;
!   const char *dash;
!   const char *slash;
!   const char *cp;
  
    dash = NULL;
    slash = NULL;
!   for (cp = name; *cp != '\0'; ++cp)
      {
        if (*cp == '-')
  	dash = cp;
+ 
        if (
  #if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__)
  	  *cp == ':' || *cp == '\\' ||
*************** deduce_name (const char *prog_name)
*** 269,292 ****
    cmd = NULL;
  
    if (dash != NULL)
!     {
!       /* First, try looking for a prefixed PROG_NAME in the
!          PROGRAM_NAME directory, with the same prefix as PROGRAM_NAME.  */
!       cmd = look_for_prog (prog_name, program_name, dash - program_name + 1);
!     }
  
    if (slash != NULL && cmd == NULL)
!     {
!       /* Next, try looking for a PROG_NAME in the same directory as
!          that of this program.  */
!       cmd = look_for_prog (prog_name, program_name, slash - program_name + 1);
!     }
  
    if (cmd == NULL)
!     {
!       /* Just return PROG_NAME as is.  */
!       cmd = xstrdup (prog_name);
!     }
  
    return cmd;
  }
--- 272,289 ----
    cmd = NULL;
  
    if (dash != NULL)
!     /* First, try looking for a prefixed PROG_NAME in the
!        PROGRAM_NAME directory, with the same prefix as PROGRAM_NAME.  */
!     cmd = look_for_prog (name, name, dash - name + 1);
  
    if (slash != NULL && cmd == NULL)
!     /* Next, try looking for a PROG_NAME in the same directory as
!        that of this program.  */
!     cmd = look_for_prog (name, name, slash - name + 1);
  
    if (cmd == NULL)
!     /* Just return PROG_NAME as is.  */
!     cmd = xstrdup (name);
  
    return cmd;
  }
*************** run (const char *what, char *args)
*** 396,409 ****
    if (dry_run)
      return 0;
  
!   pid = pexecute (argv[0], (char * const *) argv, program_name, temp_base,
  		  &errmsg_fmt, &errmsg_arg, PEXECUTE_ONE | PEXECUTE_SEARCH);
  
    if (pid == -1)
      {
        int errno_val = errno;
  
!       fprintf (stderr, "%s: ", program_name);
        fprintf (stderr, errmsg_fmt, errmsg_arg);
        fprintf (stderr, ": %s\n", strerror (errno_val));
        return 1;
--- 393,406 ----
    if (dry_run)
      return 0;
  
!   pid = pexecute (argv[0], (char * const *) argv, prog_name, temp_base,
  		  &errmsg_fmt, &errmsg_arg, PEXECUTE_ONE | PEXECUTE_SEARCH);
  
    if (pid == -1)
      {
        int errno_val = errno;
  
!       fprintf (stderr, "%s: ", prog_name);
        fprintf (stderr, errmsg_fmt, errmsg_arg);
        fprintf (stderr, ": %s\n", strerror (errno_val));
        return 1;
*************** strhash (const char *str)
*** 479,491 ****
  static void
  usage (FILE *file, int status)
  {
!   fprintf (file, _("Usage %s <option(s)> <object-file(s)>\n"), program_name);
    fprintf (file, _("  Generic options:\n"));
    fprintf (file, _("   --quiet, -q            Work quietly\n"));
    fprintf (file, _("   --verbose, -v          Verbose\n"));
    fprintf (file, _("   --version              Print dllwrap version\n"));
    fprintf (file, _("   --implib <outname>     Synonym for --output-lib\n"));
!   fprintf (file, _("  Options for %s:\n"), program_name);
    fprintf (file, _("   --driver-name <driver> Defaults to \"gcc\"\n"));
    fprintf (file, _("   --driver-flags <flags> Override default ld flags\n"));
    fprintf (file, _("   --dlltool-name <dlltool> Defaults to \"dlltool\"\n"));
--- 476,488 ----
  static void
  usage (FILE *file, int status)
  {
!   fprintf (file, _("Usage %s <option(s)> <object-file(s)>\n"), prog_name);
    fprintf (file, _("  Generic options:\n"));
    fprintf (file, _("   --quiet, -q            Work quietly\n"));
    fprintf (file, _("   --verbose, -v          Verbose\n"));
    fprintf (file, _("   --version              Print dllwrap version\n"));
    fprintf (file, _("   --implib <outname>     Synonym for --output-lib\n"));
!   fprintf (file, _("  Options for %s:\n"), prog_name);
    fprintf (file, _("   --driver-name <driver> Defaults to \"gcc\"\n"));
    fprintf (file, _("   --driver-flags <flags> Override default ld flags\n"));
    fprintf (file, _("   --dlltool-name <dlltool> Defaults to \"dlltool\"\n"));
*************** main (int argc, char **argv)
*** 624,630 ****
  
    char *image_base_str = 0;
  
!   program_name = argv[0];
  
  #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
    setlocale (LC_MESSAGES, "");
--- 621,627 ----
  
    char *image_base_str = 0;
  
!   prog_name = argv[0];
  
  #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
    setlocale (LC_MESSAGES, "");
*************** main (int argc, char **argv)
*** 688,694 ****
  	  verbose = 1;
  	  break;
  	case OPTION_VERSION:
! 	  print_version (program_name);
  	  break;
  	case 'e':
  	  entry_point = optarg;
--- 685,691 ----
  	  verbose = 1;
  	  break;
  	case OPTION_VERSION:
! 	  print_version (prog_name);
  	  break;
  	case 'e':
  	  entry_point = optarg;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]