www.delorie.com/archives/browse.cgi   search  
Mail Archives: pgcc/1998/07/13/22:47:56

X-pop3-spooler: POP3MAIL 2.1.0 b 4 980420 -bs-
Message-ID: <19980713232040.61103@cerebro.laendle>
Date: Mon, 13 Jul 1998 23:20:40 +0200
From: Marc Lehmann <pcg AT goof DOT com>
To: Vincent Diepeveen <diep AT xs4all DOT nl>
Cc: beastium <beastium-list AT Desk DOT nl>
Subject: Re: weird things of gcc
Mail-Followup-To: Vincent Diepeveen <diep AT xs4all DOT nl>,
beastium <beastium-list AT desk DOT nl>
References: <3 DOT 0 DOT 32 DOT 19980711232836 DOT 0097a3f0 AT xs4all DOT nl>
Mime-Version: 1.0
In-Reply-To: <3.0.32.19980711232836.0097a3f0@xs4all.nl>; from Vincent Diepeveen on Sat, Jul 11, 1998 at 11:28:40PM +0100
X-Operating-System: Linux version 2.1.108 (root AT cerebro) (gcc version pgcc-2.91.43 19980628 (gcc2 ss-980502 experimental))
Status: RO
Lines: 60

On Sat, Jul 11, 1998 at 11:28:40PM +0100, Vincent Diepeveen wrote:

> first of all, why doesn't gcc have a predefined function like msvc++ have 
> called:
>   max() and min()?

there aren't max() and min() functions in C, they are a proprietary msvc++
extension (you can look this up in msvc++'s manual)

You can define the MAX and MIN macros yourself, if you want to program in C,
rather than in Microsoft's proprietary dialect whose only purpose is to tie
you to the outdated windows platform.

Another solution might be to include sys/param.h on linux (with the same
caveats as above)

> int ReturnFloepWindow(char *sOut) {
>   printf("%s\n",sOut);
>   gets(sOut);
>   return(true);
> }
> 
> Now gcc gives next warning:
> 
> "the 'gets' function is dangerous and should not be used."

1. thats not a gcc warning but a glibc warning (this distinction
   is not very important)
2. its only a warning, you can ignore it if you want
3. its true, you should use fgets instead

the reason is that "gets" is a big security hole in many programs and a
nuisance causing mysterious coredumps in almost all programs, as "gets"
doesn't do any range-checking.

> What the #$$##$ does gcc think it's saying to me, am i not allowed to
> get a string from the keyboard, is there a bug in this function?

you are safe, its not a bug per-se, its just a dangerous function
you can use but you shouldn't.

look at this that way: gcc (or glibc in this case), only tried to advise you
to write reliable programs. If you enable all warnings (with "-W -Wall"), it
will warn you bout numerous things, including things that are perfectly safe
in some environments, but broken in others, like this:

char latin1_to_codepage437[256];
char cp437, latin1;

cp437 = latin1_to_codepage437 [ latin1 ];

which will work on some machines but not on others.

      -----==-                                              |
      ----==-- _                                            |
      ---==---(_)__  __ ____  __       Marc Lehmann       +--
      --==---/ / _ \/ // /\ \/ /       pcg AT goof DOT com       |e|
      -=====/_/_//_/\_,_/ /_/\_\                          --+
    The choice of a GNU generation                        |
                                                          |

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019