www.digitalmars.com         C & C++   DMDScript  

c++.dos.16-bits - spawnl problem

reply "Sergiy Yakovyn" <ysv_ ukr.net> writes:
Hi all!
Next code:
#include <stdio.h>
#include <process.h>
#include <stdlib.h>

int main()
{
  char const* progName="Test.exe";
  int ret=spawnl(P_WAIT, progName, progName, 0);
  printf("RunProg::run: %s %d %d %d\n", progName, ret, errno, _doserrno);
  return 0;
}

after compiling with dm compiler (Digital Mars Compiler Version 8.41n) and
using sdl.lib (19.03.2003  11:42           397 312 sdl.lib)
by bat file with next contenst:

set path=d:\dm\bin
dmc -o -4 -ml TstRunPg.cpp
del *.obj

I get next output:
RunProg::run: Test.exe -1 7 0

I can't understand what is my fault.
I've tried this program under bc 3.1 and it runs Test.exe.
Please help me!

Sergiy Yakovyn
Mar 20 2005
parent reply "Walter" <newshound digitalmars.com> writes:
Use NULL, not 0, to terminate the argument list to spawnl:

    int ret=spawnl(P_WAIT, progName, progName, NULL);

Then it works. NULL is a 4 byte value with the L memory model, whereas 0 is
2 bytes.
Apr 18 2005
parent reply "Sergiy Yakovyn" <ysv_ ukr.net> writes:
int ret=spawnl(P_WAIT, progName, progName, NULL);
The example above doesn't work.
Work only when I've written as below:
spawnl(P_WAIT, mProgName, mProgName, NULL, NULL).
It looks like NULL is two bytes value at large model under some
circumstance.
I am using next files:
#include <process.h>
#include <stdlib.h>
#include <types.h>

I think it's because next definition in stdlib.h (I compile C++ file). For C
files you are right.
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif

"Walter" <newshound digitalmars.com> сообщил/сообщила в новостях следующее:
news:d40oac$1eam$1 digitaldaemon.com...
 Use NULL, not 0, to terminate the argument list to spawnl:

    int ret=spawnl(P_WAIT, progName, progName, NULL);

 Then it works. NULL is a 4 byte value with the L memory model, whereas 0
 is
 2 bytes.
Mar 12 2006
parent %u <shiv_com yahoo.com> writes:
give me example of spawnl function
Jul 20 2007