This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


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

__errno() function is missing


I am trying to compile tree-4.1(Tcl/Tk extension),
the build crashes at the link stage.
Here is the error message:
./src/libTkTree.a(error.o)(.text+0x17e):error.cc: undefined reference to
`__errno(void)
./src/libTkTree.a(error.o)(.text+0x188):error.cc: undefined reference to
`__errno(void)
./src/libTkTree.a(error.o)(.text+0x29c):error.cc: undefined reference to
`__errno(void)
./src/libTkTree.a(error.o)(.text+0x2f4):error.cc: undefined reference to
`__errno(void)
g++: Internal compiler error: program ld got fatal signal 1

Is this function missing or do I need to add special libraries?

Here is the Error.c file
------------------ begin ---------------------------------
#include <stdlib.h>
#include <string.h>
#include <iostream.h>
#include <strstream.h>
#include <errno.h>
#include <stdio.h>
#include "error.h"


// static variable holding text of last error messages
static char errmsg_[1024];

// error code (see defines in <sys/errno.h> for values)

static int errno_ = 0;

// optional error handler, to be called with error message
static void (*errhandler_)(const char*) = NULL;


/*
 * global error reporting routine
 */
int error(const char* msg1, const char* msg2, int code)
{
    char buf[sizeof(errmsg_)];
    ostrstream os(buf, sizeof(buf));
    os << msg1 << msg2 << ends;
    
    if (errhandler_)
	(*errhandler_)(buf);

#ifdef DEBUG
    cerr << "debug: " << buf << endl;
#endif

    errno_ = code;
    strcpy(errmsg_, buf);
    return ERROR;
}


/*
 * report the error, including system error code
 */
int sys_error(const char* msg1, const char* msg2)
{
    extern int sys_nerr;
    extern char *sys_errlist[];
    extern int errno;

    if (errno < 0 || errno >= sys_nerr)
	return error(msg1, msg2);

    char buf[sizeof(errmsg_)];
    ostrstream os(buf, sizeof(buf));
    os << msg1 << msg2 << ": " << sys_errlist[errno] << ends;

    if (errhandler_)
	(*errhandler_)(buf);

#ifdef DEBUG
    cerr << "debug: " << buf << endl;
#endif

    errno_ = errno;
    strcpy(errmsg_, buf);
    return ERROR;
}


/* 
 * return the text of the previous error message
 */
char* last_error() 
{
    return errmsg_;
}


/* 
 * return the error code for the previous error
 */
int last_error_code() 
{
    return errno_;
}


/* 
 * reset the last_error buf to empty 
 */
void clear_error()
{
    errmsg_[0] = '\0';
}


/*
 * set a routine to be called with the text of error messages
 * when they occur. The argument is a pointer to an error 
 * handler:
 *
 *       void errhandler(const char* msg);
 *
 * The return value is a pointer to the previous error handler, or NULL,
 * if none was defined.
 */
void (*set_error_handler(void (*errhandler)(const char*)))(const char*)
{
    void (*old_handler)(const char*) = errhandler_;
    errhandler_ = errhandler;
    return old_handler;
}


/*  
 * print the given message on stderr (may be used as an error
 * handler)
 */
void print_error(const char* msg)
{
    cerr << msg << endl;
}
------------------------ end ---------------------------------------

Any help is appreciated.

TIA

Gusel Bischoff
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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