www.digitalmars.com         C & C++   DMDScript  

c++ - Symbol Undefined __exception

reply "David Grimes" <dgrimes friberg.us> writes:
main.c:
#include <math.h>
#include "a.h"

int main(void){
 exception("math.h");
 return 0;
}

a.h:
void exception(char *string);

a.c:
#include <stdio.h>

void exception(char *string)
{
 printf("Exception: %s\n", string);
}
----------------------------------------
dmc main.c a.c
main.obj(main)
 Error 42: Symbol Undefined __exception

If math.h is included in main.c the compiler reports the above error.
According to the latest C standard "exception" is not reserved word nor part
of the standard math library.

David
Feb 16 2004
parent Phil Thompson <phil electricvisions.com> writes:
If you look in math.h exception is defined as a struct unless you do:

#define _EXCEPTION_DEFINED


Including this define in your code fixes the problem but I'd probably 
choose a different name for your function.


Regards,
Phil


David Grimes wrote:

 main.c:
 #include <math.h>
 #include "a.h"
 
 int main(void){
  exception("math.h");
  return 0;
 }
 
 a.h:
 void exception(char *string);
 
 a.c:
 #include <stdio.h>
 
 void exception(char *string)
 {
  printf("Exception: %s\n", string);
 }
 ----------------------------------------
 dmc main.c a.c
 main.obj(main)
  Error 42: Symbol Undefined __exception
 
 If math.h is included in main.c the compiler reports the above error.
 According to the latest C standard "exception" is not reserved word nor part
 of the standard math library.
 
 David
 
 
Feb 17 2004