www.digitalmars.com         C & C++   DMDScript  

D - C System?

reply "Carlos" <carlos8294 msn.com> writes:
Hi
I've tried to automate my compiling, so I decided to write a small program.
But I can't find anything like C system() function to pass something to the
OS. How can I do it?
Thanks
May 15 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:abuv1c$tn1$1 digitaldaemon.com...
 Hi
 I've tried to automate my compiling, so I decided to write a small

 But I can't find anything like C system() function to pass something to

 OS. How can I do it?
 Thanks

Just call the C one: extern (C) int system(char *);
May 15 2002
parent reply "anderson" <anderson firestar.com.au> writes:
There seems to be a heavy reliance on C (and why shouldn't there be), which
means a whole load of externs need to be written. It'd by nice if someone
wrote a library or two with all the common ones, just to get things up an
running. Or perhaps have it as an optional automatic IDE/Complier task that
would recognise common C lib functions (by scanning .h files) and add them
in.

I know it says in the D docos that D is speedup by not scanning header
files, but perhaps a separate tool could be written that would only need to
be run (by the programmer) when a new C extern function was added.  I'd be
willing to have a go at that when I get some spare time (not likely), and if
there's much demand for it.

I know D want's to keep separate from C, but something to help stop reduce
extra so called, dirty code would be good.

PS - I'll probably get flamed for this, but adding an externs doubles the
amount of code needed if you only make one call to system (or any other
external function).

Me-page
www.hohums.tech.nu

"Walter" <walter digitalmars.com> wrote in message
news:abvgj4$1bob$1 digitaldaemon.com...
 "Carlos" <carlos8294 msn.com> wrote in message
 news:abuv1c$tn1$1 digitaldaemon.com...
 Hi
 I've tried to automate my compiling, so I decided to write a small

 But I can't find anything like C system() function to pass something to

 OS. How can I do it?
 Thanks

Just call the C one: extern (C) int system(char *);

May 16 2002
next sibling parent reply "Pavel Minayev" <evilone omen.ru> writes:
"anderson" <anderson firestar.com.au> wrote in message
news:ac0463$1ud0$1 digitaldaemon.com...

 There seems to be a heavy reliance on C (and why shouldn't there be),

 means a whole load of externs need to be written. It'd by nice if someone
 wrote a library or two with all the common ones, just to get things up an
 running. Or perhaps have it as an optional automatic IDE/Complier task

 would recognise common C lib functions (by scanning .h files) and add them
 in.

I believe that all ANSI C functions are to be imported by Phobos in the appropriate modules. It's just Walter doesn't have time to do it all. Anyhow, you have the package "c", and modules stdlib and stdio there: import c.stdlib; import c.stdio; Those functions that aren't there, will probably be, but for now, just declare them (or, as you've suggested, write a module...).
May 16 2002
parent "anderson" <anderson firestar.com.au> writes:
Thanks,

"Pavel Minayev" <evilone omen.ru> wrote in message
news:ac0dg9$26pd$1 digitaldaemon.com...
 "anderson" <anderson firestar.com.au> wrote in message
 news:ac0463$1ud0$1 digitaldaemon.com...

 There seems to be a heavy reliance on C (and why shouldn't there be),

 means a whole load of externs need to be written. It'd by nice if


 wrote a library or two with all the common ones, just to get things up


 running. Or perhaps have it as an optional automatic IDE/Complier task

 would recognise common C lib functions (by scanning .h files) and add


 in.

I believe that all ANSI C functions are to be imported by Phobos in the appropriate modules. It's just Walter doesn't have time to do it all. Anyhow, you have the package "c", and modules stdlib and stdio there: import c.stdlib; import c.stdio; Those functions that aren't there, will probably be, but for now, just declare them (or, as you've suggested, write a module...).

May 16 2002
prev sibling parent "Walter" <walter digitalmars.com> writes:
"anderson" <anderson firestar.com.au> wrote in message
news:ac0463$1ud0$1 digitaldaemon.com...
 There seems to be a heavy reliance on C (and why shouldn't there be),

 means a whole load of externs need to be written. It'd by nice if someone
 wrote a library or two with all the common ones, just to get things up an
 running. Or perhaps have it as an optional automatic IDE/Complier task

 would recognise common C lib functions (by scanning .h files) and add them
 in.

Some of them are done, they're in the c.* packages. Writing a tool to do it turns out to be imperfect because of the heavy use of macros typical in C header files.
 PS - I'll probably get flamed for this, but adding an externs doubles the
 amount of code needed if you only make one call to system (or any other
 external function).

If you add it to the appropriate c.* import, it only has to be done once.
May 16 2002