From: Arno v. A. <ar...@mo...> - 2001-03-23 07:21:26
|
Hello everybody, I used Mingw32 gcc (msvcrt 2.95.2 version) and I have a strange problem. I have a piece of code of which gcc generates a warning: char str[255]; strcpy(str, getenv("COMSPEC")); GCC says: 'warning: passing arg 2 of 'strcpy' makes pointer from integer without a cast. The generated executable works fine and I've tried everything to make the warning go away. Is this a bug in gcc or am I doing something wrong?? Note that the same piece of code gives no warning at all in BC 3.1++. I hope somebody can help me, regards Arno van Amersfoort -- -------------------------------------------------------------- Ing. Arno van Amersfoort Department of Electronics - FSC Huygens Laboratory Leiden University P.O. Box 9504 Niels Bohrweg 2 2333 CA Leiden Holland -------------------------------------------------------------- Phone : +31-(0)71-5275959 Fax : +31-(0)71-5275829 -------------------------------------------------------------- E-mail : ar...@mo... -------------------------------------------------------------- |
From: Georg F. <fu...@is...> - 2001-03-23 09:10:51
|
Hello Arno, I suppose you do *not* include the file stdlib.h in your program. This file is compiled without any warning: // $Id: get_env.c,v 1.1 2001/03/23 08:55:27 fusz Exp fusz $ #include <stdio.h> #include <string.h> #include <stdlib.h> int main( void ) { char str[255]; int re = 0; //----------------------------------------------------- strcpy(str, getenv("COMSPEC")); printf( "COMSPEC = %s\n", str ); printf( "Ready, press ENTER" ); getchar(); return re; } Arno van Amersfoort wrote: > > Hello everybody, > > I used Mingw32 gcc (msvcrt 2.95.2 version) and I have a strange problem. > I have a piece of code of which gcc generates a warning: > > char str[255]; > > strcpy(str, getenv("COMSPEC")); > > GCC says: 'warning: passing arg 2 of 'strcpy' makes pointer from integer > without a cast. The generated executable works fine and I've tried > everything to make the warning go away. Is this a bug in gcc or am I > doing something wrong?? > Note that the same piece of code gives no warning at all in BC 3.1++. > > I hope somebody can help me, > > regards > > Arno van Amersfoort > > -- > -------------------------------------------------------------- > Ing. Arno van Amersfoort > Department of Electronics - FSC > Huygens Laboratory > Leiden University > P.O. Box 9504 > Niels Bohrweg 2 > 2333 CA Leiden > Holland > -------------------------------------------------------------- > Phone : +31-(0)71-5275959 > Fax : +31-(0)71-5275829 > -------------------------------------------------------------- > E-mail : ar...@mo... > -------------------------------------------------------------- > > _______________________________________________ > MinGW-users mailing list > Min...@li... > > You may change your MinGW Account Options at: > http://lists.sourceforge.net/lists/listinfo/mingw-users -- Georg Fusz Technische Universitaet Berlin, Germany Fon: Uni.: +49 30 314 26 884 privat: +49 30 815 30 32 Handy: +49 173 20 10 696 Homepage: http://www.cadlab.tu-berlin.de/~fusz/ |