RE: [Dev-C++] BC++, gcc and Win98SE shell
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ya...> - 2002-02-25 00:48:54
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of gi...@li...
> Sent: Monday, February 25, 2002 12:38 AM
> To: dev...@so...
> Subject: RE: [Dev-C++] BC++, gcc and Win98SE shell
>
>
> Sorry for my previous post, it was not very clear.
>
> Let me try again.
>
> The test program is, this time, a little different:
>
> /* echo.c */
> #include <stdio.h>
> int main(int argc, char *argv[])
> {
> while (--argc > 0)
> printf("%s%s", *++argv, (argc > 1) ? " ": "");
> printf("\n");
> return 0;
> }
>
> IMHO the above is more or less equivalent to the program I
> posted before
> but I changed in the hope that Ioannis won't yell at me this time :-)
>
> Anyway the program is not the point, it is just a mean to
> show that: when I use a program compiled by gcc, it seems
> that the shell expands
> wildcards before invoking the program (as it should always
> be), instead
> when I compile the same program using BC++, the shell does
> not expand the
> wildcards.
>
> To prove it, what I did was:
> 1. create a directory named c:\temp
> 2. used the program "touch" (a Borland tool) to create:
> c:\temp\foo.c and
> c:\temp\bar.c
> 3. switched to the directory c:\temp
> 4. issued the command: echo_g *.c
>
> The ouput of the command was:
>
> bar.c foo.c
>
> This means that the shell expanded "*.c" into "bar.c foo.c", the two
> arguments were then echoed by the program "echo_g" (where the
> "_g" means
> compiled using gcc).
>
> Instead if I use the version of echo compiled by BC++ (named
> "echo_b.exe"),
> that is, when step #4 becomes:
>
> 4. issued the command: echo_b *.c
>
> The output is:
>
> *.c
>
> This means that the shell did not expand "*.c". Or, if you
> prefer, I have
> the same ANSI C89 program give two different outputs,
> according to which
> compiler was used to build the executable. I have no
> explanation for this,
> other than there is some bug in the shell.
This is compiler bug. **argv represents the passed arguments as a string
and i think that the behavior of BCC is the correct (expected) here.
The standard requires the exact arguments to be represented as C-strings
in *argv[] and then if the programmer wishes he can execute system
commands like system("dir *.c");
The C & C++ standards write:
"int main(int argc, char* argv[]) { /* ... */ }
In the latter form argc shall be the number of arguments passed to the
program from the environment in
which the program is run."
>
> My questions are
> 1. Why is the Windows shell (or command.com, if you prefer) acting
> differently?
I do not think it is the environment. I rather think is the use of the
environment from the produced exe (produced by the compiler).
> 2. Is this happening on my Win98SE or is it happening on
> other versions of
> Windows too?
It is happening in my win2k too and i use the cmd.exe .
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.d2g.com
* Alternative URL: http://run.to/noicys
|