slang-users mailing list

[2000 Date Index] [2000 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: S-Lang Error: Duplicate Definition: ...


Joachim <nuklear@xxxxxxxxxxxxxx> wrote:
>but when I run the program it exists normally with the following error,
>when the input() function 
>is called the second time
>
>S-Lang Error: Duplicate Definition: Type Name Array_Type already exists
[...]
>int input(char *string, int length)
>{
[...]
>
>                if ((-1 == SLang_init_slang ())    /* basic interpreter
>functions */
>                || (-1 == SLang_init_slmath ()) /* sin, cos, etc... */
>                || (-1 == SLang_init_slunix ()) /* unix system calls */
>                || (-1 == SLang_init_slfile ())) /* file I/O */
>              exit (0);

You are only supposed to call these init functions one time and only
then if you intend to you the slang interpreter.  If this is your
intention, I would move this code fragment out of this function to
some place where it is guaranteed to be called only one time.
Alternatively, you could use something along the lines of

  int input (char *string, int length)
  {
     static int initialized;
     
     if (initialized == 0)
       {
          if ((-1 == SLang_init_slang ())
	        .
		.)
	   exit (0);
	  initialized = 1;
       }
     [...]
  }

but it is better to put it somewhere else.

Finally, instead of calling the various SLang_init_* interpreter
functions, you may just want to call SLang_init_all.  See
slang/src/slintall.c for its definition.

--John
	     


[2000 date index] [2000 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]